matplotlib.category#
Plotting of string "category" data: plot(['d', 'f', 'a'], [1, 2, 3]) will
plot three points with x-axis values of 'd', 'f', 'a'.
See Plotting categorical variables for an example.
The module uses Matplotlib's matplotlib.units mechanism to convert from
strings to integers and provides a tick locator, a tick formatter, and the
UnitData class that creates and stores the string-to-integer mapping.
- class matplotlib.category.StrCategoryConverter[source]#
Bases:
ConversionInterface
- class matplotlib.category.StrCategoryFormatter(units_mapping)[source]#
Bases:
FormatterString representation of the data at every tick.
- Parameters:
- units_mappingdict
Mapping of category names (str) to indices (int).
- format_ticks(values)[source]#
Return the tick label strings for all values.
This is the public API for generating tick labels. It calls
set_locsto configure context-dependent formatting state before delegating to__call__for each individual value.The output may contain mathtext or LaTeX markup.
Use this method (rather than
__call__) whenever formatting a complete set of tick values, so that formatters which need to see all tick locations (e.g. to determine precision, offsets, or which date components to display) can work correctly.
- class matplotlib.category.StrCategoryLocator(units_mapping)[source]#
Bases:
LocatorTick at every integer mapping of the string data.
- Parameters:
- units_mappingdict
Mapping of category names (str) to indices (int).