Jul-04-2019, 08:23 AM
I didn't explore source code of matplotlib in detail, but in general, computation of values where ytick labels will be shown is performed by a
matplotlib.ticker
instance. By default, it is ticker.AutoLocator
: from matplotlib.ticker import AutoLocator aul = AutoLocator() aul.tick_values(1, 3)
Output:array([1. , 1.25, 1.5 , 1.75, 2. , 2.25, 2.5 , 2.75, 3. ])
from pylab import * plt.plot([1,2,3]) plt.show() # yields a graph with ticks placed in above positionsThis default behavior is made for convenience, and it could be easily overridden using
axes.set_yticks
etc. Note, there are minor and major ticks (we are talking about major one here), so underlying machinery is quite tricky.