Hi probably quite a simple question but..
When plotting a graph using matplotlib.pyplot my Y axis goes from -0.04 to 0.03 which is fine but there are 8 labels for increments (eg 0.03,0.02,0.01 etc.). I need more maybe 16 or so.
Thanks for your help
set_yticks() to change the tick locations. For example:
import scipy, pylab fig = pylab.figure() ax = fig.add_subplot(1,1,1) ax.plot(scipy.randn(8)) ax.set_yticks(scipy.arange(-1.5,1.5,0.25)) fig.show()
pylab.yticks() is another option.
Matplotlib has several different algorithms for choosing tick locations automatically, and e.g. LinearLocator or MaxNLocator may suit your purpose. See the major_minor demo for how to use Locators in general, and the ticker api documentation for the various Locators available. The documentation for the individual classes is somewhat sparse, but guessing based on the argument names tends to work fine.