Formatter¶
-
Formatter(formatter, *args, date=False, **kwargs)[source]¶ Returns a
Formatterinstance, used to interpret thexformatter,xformatter_kw,yformatter, andyformatter_kwarguments when passed toformat, and theformatterandformatter_kwarguments when passed to colorbar methods wrapped bycolorbar_wrapper.- Parameters
formatter (
Formatter, str, list of str, or function) – IfFormatter, the object is returned.If list of strings, ticks are labeled with these strings. Returns a
FixedFormatterinstance.If function, labels will be generated using this function. Returns a
FuncFormatterinstance.If string, there are 4 possibilities:
If string contains
'%'anddateisFalse, ticks will be formatted using the C-notationstring % numbermethod. See this page for a review.If string contains
'%'anddateisTrue, datetimestring % numberformatting is used. See this page for a review.If string contains
{x}or{x:...}, ticks will be formatted by callingstring.format(x=number).In all other cases, a dictionary lookup is performed (see below table).
Key
Class
Description
'null','none'No tick labels
'auto'New default tick labels for axes
'simple'New default tick labels for e.g. contour labels
'frac'Rational fractions
'date'Default tick labels for datetime axes
'datestr'Date formatting with C-style
string % formatnotation'concise'More concise date labels introduced in matplotlib 3.1
'scalar'Old default tick labels for axes
'strmethod'From the
string.formatmethod'formatstr'From C-style
string % formatnotation'log','sci'For log-scale axes with scientific notation
'math'For log-scale axes with math text
'logit'For logistic-scale axes
'eng'Engineering notation
'percent'Trailing percent sign
'fixed'List of strings
'index'List of strings corresponding to non-negative integer positions along the axis
'theta'Formats radians as degrees, with a degree symbol
'pi'FracFormatterpresetFractions of \(\pi\)
'e'FracFormatterpresetFractions of e
'deg'SimpleFormatterpresetTrailing degree symbol
'deglon'SimpleFormatterpresetTrailing degree symbol and cardinal “WE” indicator
'deglat'SimpleFormatterpresetTrailing degree symbol and cardinal “SN” indicator
'lon'SimpleFormatterpresetCardinal “WE” indicator
'lat'SimpleFormatterpresetCardinal “SN” indicator
date (bool, optional) – Toggles the behavior when
formattercontains a'%'sign (see above).*args, **kwargs – Passed to the
Formatterclass.
- Returns