AutoFormatter¶
-
class
AutoFormatter
(*args, zerotrim=None, precision=None, tickrange=None, prefix=None, suffix=None, negpos=None, **kwargs)[source]¶ Bases:
matplotlib.ticker.ScalarFormatter
The new default formatter, a simple wrapper around
ScalarFormatter
. Differs fromScalarFormatter
in the following ways:Trims trailing zeros if any exist.
Allows user to specify range within which major tick marks are labelled.
Allows user to add arbitrary prefix or suffix to every tick label string.
- Parameters
zerotrim (bool, optional) – Whether to trim trailing zeros. Default is
rc[‘axes.formatter.zerotrim’]
=True
.tickrange ((float, float), optional) – Range within which major tick marks are labelled.
prefix, suffix (str, optional) – Prefix and suffix for all strings.
negpos (str, optional) – Length-2 string indicating the suffix for “negative” and “positive” numbers, meant to replace the minus sign. This is useful for indicating cardinal geographic coordinates.
*args, **kwargs – Passed to
ScalarFormatter
.
Warning
The matplotlib
ScalarFormatter
determines the number of significant digits based on the axis limits, and therefore may truncate digits while formatting ticks on highly non-linear axis scales likeLogScale
. We try to correct this behavior with a patch.Methods Summary
__call__
(x[, pos])Convert number to a string.