Last active
February 3, 2021 17:13
-
-
Save hashABCD/6b465c6a31786b63e64b253b9ac484bd to your computer and use it in GitHub Desktop.
Quadrant Analysis
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
How to perform a quadrant analysis using two variables in python