Reputation: 630
This should work but it does not?
plt.figure()
plt.plot(x)
plt.xticks(range(4), [2, 64, 77, 89]) # works
f, ax = plt.subplots(nrows=2, ncols=2)
ax[0, 0].plot(x)
ax[0, 0].set_xticks(range(4), [2, 64, 77, 89]) # does not work
Upvotes: 5
Views: 5174
Reputation: 25363
When using the object orientated API (as in your second example), the functions to set the tick locations and the tick labels are separate - ax.set_xticks
and ax.set_xticklabels
. Therefore, you will need:
f, ax = plt.subplots(nrows=2, ncols=2)
ax[0, 0].plot(x)
ax[0, 0].set_xticks(range(4))
ax[0, 0].set_xticklabels([2, 64, 77, 89])
Upvotes: 5