Matplotlib globaly set interval / tick count / tickslabels

In my stories, yticks are too close to each other (since I changed the font of yticks). Therefore, I would like to limit / correct the number of yticks. Since I have hundreds of stories, I would like to change this to “globaly” (in matplotlibrc or using a dictionary, etc.).

Any ideas? Something like ax.xaxis.set_major_locator(MaxNLocator(4))that, but globally

By the way: I cannot find how to refer to axes without using a subtitle. Any clues?

+3
source share
1 answer

You can change __init__the AutoLocator method to your function before any chart:

import pylab as pl
from matplotlib import ticker

def AutoLocatorInit(self):
    ticker.MaxNLocator.__init__(self, nbins=4, steps=[1, 2, 5, 10])
ticker.AutoLocator.__init__ = AutoLocatorInit

pl.plot(pl.randn(100))
pl.figure()
pl.hist(pl.randn(1000), bins=40)
pl.show()
+5
source

All Articles