lair.plotter.log10formatter#
- lair.plotter.log10formatter(x, pos, deci=0)[source]#
Format ticks to log 10 format with deci number of decimals.
- Parameters:
- Returns:
str – Formatted tick label.
- Return type:
See also
matplotlib.ticker.FuncFormatterWraps a function as a tick formatter.
Examples
>>> from functools import partial >>> import numpy as np >>> import xarray as xr >>> from lair.plotter import log10formatter >>> x = np.linspace(-3, 3, 40) >>> data = xr.DataArray( ... 10 ** (np.add.outer(x, x) / 2), ... coords={"lat": x, "lon": x}, ... dims=("lat", "lon"), ... ) >>> mesh = np.log10(data).plot( ... cbar_kwargs={"format": partial(log10formatter, deci=1)} ... )