1

How do you have category names as the xlabel without it all squeezing together? Below is my dictionary. I actually have my keys and values mixed up due to sorting, but the code is fine.

2 : theatre
16 : silent
234 : western
1230 : mystery
1296 : animated
1496 : fantasy
1584 : science
1922 : adventure
2176 : family
2767 : horror
4122 : action
4281 : romance
4804 : thriller
7105 : comedy
11147 : drama

keys, values = df_decades_obs_dict.values(), df_decades_obs_dict.keys()
plt.bar(range(len(values)), values, color='g')
plt.xticks(range(len(values)), keys)
plt.show()

Here is a photo of what the graph looks like:

enter image description here

handavidbang
  • 593
  • 1
  • 6
  • 19

1 Answers1

3

You can use plt.xticks(range(len(values)), keys,rotation=90) to rotate. more info in docs

Equinox
  • 6,483
  • 3
  • 23
  • 32