You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
19 lines
555 B
Python
19 lines
555 B
Python
6 years ago
|
from matplotlib import pyplot as plt
|
||
|
|
||
|
movies = ["Annie Hall", "Ben-hur", "Casablanca", "Gandhi", "West Side Story"]
|
||
|
|
||
|
num_oscars = [5, 11, 3, 8, 10]
|
||
|
|
||
|
# Bars are by default 0.8 width. We are adding 0.1 to the left coordinates so that all bars are centered
|
||
|
xs = [i + 0.1 for i, _ in enumerate(movies)]
|
||
|
|
||
|
# Plot the bars with left-x coordinates and heights (num_oscars)
|
||
|
|
||
|
plt.bar(xs, num_oscars)
|
||
|
plt.ylabel("# of Oscars")
|
||
|
plt.title("Movies")
|
||
|
|
||
|
# label x-axis with movie names at bar centers
|
||
|
plt.xticks([i + 0.1 for i, _ in enumerate(movies)], movies)
|
||
|
plt.show()
|