PlotLabeller¶
- class stonerplots.PlotLabeller(*args, x=<class 'stonerplots.format.TexEngFormatter'>, y=<class 'stonerplots.format.TexEngFormatter'>, z=<class 'stonerplots.format.TexEngFormatter'>, **kargs)¶
Bases:
TrackNewFiguresAndAxesAdjust the x and y axis tick formatters of plots created in the context handler.
- Keyword Arguments:
- x,y,z (Formatter,Locator or tuple or list of Formatter or Locator):
Ticker formatter and locator classes or instances.
- Notes:
The PlotLabeller Context handler will apply any given axis tick locators and formatters to any plots created inside the context handler. If Formatter/Locator classes are passed in, these are instantiated with default parameters.
Both major and minor formatters/locators are handled: if a minor formatter/locator is already set (i.e., not NullFormatter), the same formatter/locator will be applied to it as well.
The default is to not change the Locator and set the Formatters to use the TexEngFormatter that renders the labels with LaTeX codes to allow proper micro signs.
- Examples:
>>> import matplotlib.pyplot as plt >>> from stonerplots.format import PlotLabeller, TexFormatter >>> with PlotLabeller(x=TexFormatter, y=TexFormatter): ... fig, ax = plt.subplots() ... ax.plot([1e6, 2e6, 3e6], [1, 2, 3]) >>> plt.show()