4

I have a plot that looks like this, and I am trying to make the x axis labels more readable:

enter image description here

This is what I tried and the error I got:

enter image description here

pr338
  • 8,730
  • 19
  • 52
  • 71

1 Answers1

17

The problem is that you are setting plt from the call to hist(), which is not what you want. It is common to import matplotlib as plt, assuming that is what was intended here:

import matplotlib.pyplot as plt

data = [1, 2, 3, 4]

p = plt.hist(data)
plt.xticks(rotation='vertical')

plt.show()

enter image description here

Tim B
  • 3,033
  • 1
  • 23
  • 28