I want to increase the yticks upto 100. It is currently 80 but i want it to be 100.
plt.yticks(np.arange(0,100,10))
but this doesn't work.
CodePudding user response:
A couple of things:
- using pyplot isn't recommended (but is still possible for the sake of backwards compatibility)
- setting the ticks or tick labels isn't recommended as those solutions fall apart when the axes limits changes.
So the solution is to
- use the object-oriented interface
- set the locator and limits directly
from matplotlib import pyplot
from matplotlib import ticker
fig, ax = pyplot.subplots(figsize=(6, 4))
ax.bar(...)
# or df.plot.bar(..., ax=ax)
ax.yaxis.set_major_locator(ticker.MultipleLocator(10))
ax.set_ylim(bottom=0, top=100)