Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change the amount of increments in pyplot axis

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

like image 569
Gish Avatar asked Jun 10 '10 09:06

Gish


1 Answers

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.

like image 138
Jouni K. Seppänen Avatar answered Nov 15 '22 00:11

Jouni K. Seppänen