PlotLabeller

class stonerplots.PlotLabeller(*args: ~typing.Any, x: type[~matplotlib.ticker.Formatter] | type[~matplotlib.ticker.Locator] | ~matplotlib.ticker.Formatter | ~matplotlib.ticker.Locator | list | tuple = <class 'stonerplots.format.TexEngFormatter'>, y: type[~matplotlib.ticker.Formatter] | type[~matplotlib.ticker.Locator] | ~matplotlib.ticker.Formatter | ~matplotlib.ticker.Locator | list | tuple = <class 'stonerplots.format.TexEngFormatter'>, z: type[~matplotlib.ticker.Formatter] | type[~matplotlib.ticker.Locator] | ~matplotlib.ticker.Formatter | ~matplotlib.ticker.Locator | list | tuple = <class 'stonerplots.format.TexEngFormatter'>, **kargs: ~typing.Any)

Bases: TrackNewFiguresAndAxes

Adjust 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 for each target ticker slot. Supplied instances are deep-copied for each slot, excluding their owning Axis, so their configuration is preserved without rebinding the caller’s instance or sharing mutable ticker state.

Both major and minor formatters/locators are handled: if a minor formatter/locator is already set (i.e., not NullFormatter/NullLocator), an independent formatter/locator is 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()