Hi all,
I’m working on the Star Wars survey project and trying to create grouped bar charts of the rankings and movies seen by gender. Everything works except my the labels for my x ticks. Here is my code:
names_map = ['The Phantom Menace', 'Attack of the Clones', 'Revenge of the Sith',
'A New Hope', 'The Empire Strikes Back', 'Return of the Jedi']
#create a bar plot of the rankings by gender
fig, ax = plt.subplots()
bar_positions = np.arange(len(names_map))
width = 0.35
men_rankings = ax.bar(bar_positions - width/2, male_rankings, width, label='Men')
women_rankings = ax.bar(bar_positions + width/2, female_rankings, width, label='Women')
ax.set_title('Movie Rankings by Gender')
ax.set_ylabel('Average Rank')
ax.legend()
ax.set_xticks(bar_positions)
ax.set_xticklabels=(names_map)
plt.show()
#create a bar plot of the movies seen by gender
fig, ax = plt.subplots()
bar_positions = np.arange(len(names_map))
width = 0.35
men_rankings = ax.bar(bar_positions - width/2, male_seen_cols, width, label='Men')
women_rankings = ax.bar(bar_positions + width/2, female_seen_cols, width, label='Women')
ax.set_title('Films Seen')
ax.set_ylabel('Respondents Who\'ve Seen the Film')
ax.legend()
ax.set_xticks(bar_positions)
ax.set_xticklabels=(names_map)
plt.show()
What I expected to happen:
The list names_map should become the xticklabels.
What actually happened:
Xticklabels don’t display at all. In fact, no matter what I do, I can’t seem to get the xticks to display any label other than the default 0-5. Anyone see anything glaringly obvious that I’m missing?
Thanks in advance!