

from matplotlib import pyplot as plt

# A bar chart is a good choice when you want to show how some quantity varies among
# some discrete set of items. 

# Example: shows how many Academy Awards were won by each of a variety of movies

movies = ["Annie Hall", "Ben-Hur", "Casablanca", "Gandhi", "West Side Story"]
num_oscars = [5, 11, 3, 8, 10]

# bars are by default width 0.8, so we'll add 0.1 to the left coordinates
# so that each bar is centered

# Was: xs = [i + 0.1 for i, _ in enumerate(movies)]

xs = [i for i, _ in enumerate(movies)]


# plot the vertical bars with left x-coordinates [in xs] and heights [in num_oscars]
plt.bar(xs, num_oscars)

# label x-axis (ticks) with movie names at bar centers
plt.xticks(xs, movies)

plt.ylabel("# of Academy Awards")

plt.title("My Favorite Movies")


plt.show()
