Skip to content

Instantly share code, notes, and snippets.

@hashABCD
Last active February 3, 2021 17:13
Show Gist options
  • Save hashABCD/6b465c6a31786b63e64b253b9ac484bd to your computer and use it in GitHub Desktop.
Save hashABCD/6b465c6a31786b63e64b253b9ac484bd to your computer and use it in GitHub Desktop.
Quadrant Analysis
plt.figure(figsize=(12,8))
#Scatterplot
sns.scatterplot(data=hdi_df, x='gni_pc', y='life_ex')
#Title
plt.title(f"G 20 Countries : {abbr['gni_pc']} vs {abbr['life_ex']}")
# x and y axis labels
plt.xlabel(abbr['gni_pc'])
plt.ylabel(abbr['life_ex'])
#Country names
for i in range(hdi_df.shape[0]):
plt.text(hdi_df.gni_pc[i], y=hdi_df.life_ex[i], s=hdi_df.Country[i], alpha=0.8)
#Quadrant Marker
plt.text(x=40000, y=68, s="Q4",alpha=0.7,fontsize=14, color='b')
plt.text(x=15000, y=68, s="Q3",alpha=0.7,fontsize=14, color='b')
plt.text(x=15000, y=78, s="Q2", alpha=0.7,fontsize=14, color='b')
plt.text(x=40000, y=78, s="Q1", alpha=0.7,fontsize=14, color='b')
# Benchmark Mean values
plt.axhline(y=hdi_df.life_ex.mean(), color='k', linestyle='--', linewidth=1)
plt.axvline(x=hdi_df.gni_pc.mean(), color='k',linestyle='--', linewidth=1)
plt.show()
@hashABCD
Copy link
Author

hashABCD commented Feb 3, 2021

How to perform a quadrant analysis using two variables in python

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment