Last active
November 12, 2017 18:12
-
-
Save suhanlee/d3be2140ad09e27a9867600787e39a14 to your computer and use it in GitHub Desktop.
matplot
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
from matplotlib import pyplot as plt | |
years = [1950, 1960, 1970, 1980, 1990, 2000, 2010] | |
gdp = [300.2, 543.3, 1075.9, 2862.5, 5979.6, 10289.7, 14958.3] | |
plt.plot(years, gdp, color='green', marker='o', linestyle='solid') | |
plt.title("Nominal GDP") | |
plt.ylabel("Billions of $") | |
plt.show() |
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
movies = ["Annie Hall", "Ben-Hur", "Casablanca", "Gandhi", "West Side Story"] | |
num_oscars = [5, 11, 3, 8, 10] | |
xs = [i + 0.1 for i, _ in enumerate(movies)] | |
plt.bar(xs, num_oscars) | |
plt.ylabel("# of Academy Awards") | |
plt.title("My Favorite Movies") | |
plt.xticks([i + 0.5 for i, _ in enumerate(movies)], movies) | |
plt.show() |
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
friends = [70, 65, 72, 63, 71, 64, 60, 64, 67] | |
minutes = [175, 170, 205, 120, 220, 130, 105, 145, 190] | |
labels = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i'] | |
plt.scatter(friends, minutes) | |
for label, friend_count, minute_count in zip(labels, friends, minutes): | |
plt.annotate(label, | |
xy=(friend_count, minute_count), | |
xytext=(5, -5), | |
textcoords='offset points') | |
plt.title("Daily Minutes vs, Number of Friends") | |
plt.xlabel("# of friends") | |
plt.ylabel("daily minutes spent on the site") | |
plt.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment