How to change the number of increments in the axis of the piplet

Hi, probably a pretty simple question, but ..
When plotting using matplotlib.pyplot, my Y axis goes from -0.04 to 0.03, which is good, but there are 8 labels for increments (for example, 0.03.0.02.0.01, etc.). I need more, maybe 16 or so.

thanks for the help

+4
source share
2 answers

Use set_yticks() to reposition checkboxes. For instance:

 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. More ticks
(source: stevetjoa.com )

+2
source

Matplotlib has several different algorithms for automatically selecting placements for tags and, for example, LinearLocator or MaxNLocator can suit your purpose. See the demo version of major_minor on how to use locators in general, and the ticker api documentation for available locators. The documentation for individual classes is somewhat sparse, but guessing based on argument names tends to work fine.

+5
source

Source: https://habr.com/ru/post/1312423/


All Articles