Formatter¶
- Formatter(formatter, *args, date=False, index=False, **kwargs)[source]¶
Return a
Formatterinstance. This function is used to interpret thexformatter,xformatter_kw,yformatter, andyformatter_kwarguments when passed toformat, and theformatterandformatter_kwarguments when passed to colorbar methods wrapped bycolorbar_extras.- Parameters
formatter (
Formatter, str, list of str, or function) – The axis formatter specification, interpreted as follows:If a
Formatterinstance already, the input argument is simply returned.If list of strings, the ticks are labeled with these strings. Returns a
FixedFormatterifindexisFalseor anIndexFormatterifindexisTrue.If a function, the labels will be generated using this function. Returns a
FuncFormatter.If a string containing
{x}or{x:...}, ticks will be formatted by callingstring.format(x=number).If a string containing
'%'anddateisFalse, ticks will be formatted using the C-stylestring % numbermethod. See this page for a review. Returns aFormatStrFormatter.If a string containing
'%'anddateisTrue, datetimestring % number`formatting is used. See this page for a review. Returns aDateFormatter.
Otherwise,
formattershould be a string corresponding to one of the “registered” formatters or formatter presets (see below table). Ifformatteris a list or tuple and the first element is a “registered” formatter name, subsequent elements are passed to the formatter class as positional arguments.Key
Class
Description
'null','none'No tick labels
'auto'New default tick labels for axes
'sci'Format ticks with scientific notation.
'simple'New default tick labels for e.g. contour labels
'sigfig'Format labels using the first
Nsignificant digits'frac'Rational fractions
'date'Default tick labels for datetime axes
'concise'More concise date labels introduced in matplotlib 3.1
'datestr'Date formatting with C-style
string % formatnotation'eng'Engineering notation
'fixed'List of strings
'formatstr'From C-style
string % formatnotation'func'Use an arbitrary function
'index'List of strings corresponding to non-negative integer positions
'log'For log-scale axes with scientific notation
'logit'For logistic-scale axes
'percent'Trailing percent sign
'scalar'Old default tick labels for axes
'strmethod'From the
string.formatmethod'theta'Formats radians as degrees, with a degree symbol
'e'FracFormatterpresetFractions of e
'pi'FracFormatterpresetFractions of \(\pi\)
'tau'FracFormatterpresetFractions of the one true circle constant \(\tau\)
'lat'AutoFormatterpresetCardinal “SN” indicator
'lon'AutoFormatterpresetCardinal “WE” indicator
'deg'AutoFormatterpresetTrailing degree symbol
'deglat'AutoFormatterpresetTrailing degree symbol and cardinal “SN” indicator
'deglon'AutoFormatterpresetTrailing degree symbol and cardinal “WE” indicator
'dms'_PlateCarreeFormatterLabels with degree/minute/second support
'dmslon'LongitudeFormatterLongitude labels with degree/minute/second support
'dmslat'LatitudeFormatterLatitude labels with degree/minute/second support
date (bool, optional) – Toggles the behavior when
formattercontains a'%'sign (see above).index (bool, optional) – Controls the behavior when
formatteris a list of strings (see above).
- Other Parameters
*args, **kwargs – Passed to the
Formatterclass.- Returns