Last active
November 6, 2017 16:00
-
-
Save 64lines/c024d1a71401ae0272c686be47c1de38 to your computer and use it in GitHub Desktop.
[PYTHON] Plotting with matplotlib
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
| import matplotlib.pyplot as plt | |
| import seaborn as sns | |
| gdp_cap = [10, 11, 12, 14, 18] | |
| life_exp = [11, 30, 13, 41, 12] | |
| # Specify c and alpha inside plt.scatter() | |
| plt.scatter(x = gdp_cap, y = life_exp, s = np.array(pop) * 2, c = col, alpha = 0.8) | |
| # Previous customizations | |
| plt.xscale('log') | |
| plt.xlabel('GDP per Capita [in USD]') | |
| plt.ylabel('Life Expectancy [in years]') | |
| plt.title('World Development in 2007') | |
| plt.xticks([1000,10000,100000], ['1k','10k','100k']) | |
| plt.xticks(rotation=90) | |
| # Additional cool customizations | |
| plt.figure() | |
| sns.countplot(x='education', hue='party', data=df, palette='RdBu') | |
| plt.xticks([0,1], ['No', 'Yes']) | |
| plt.show() | |
| # Show the plot | |
| plt.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment