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:
matplotlib.units.ConversionInterface-
static
axisinfo(unit, axis)[source]¶ Set the default axis ticks and labels.
Parameters: unit :
UnitDataobject string unit information for value
axis :
Axisaxis for which information is being set
Returns: axisinfo :
AxisInfoInformation to support default tick labeling
-
static
convert(value, unit, axis)[source]¶ Convert strings in value to floats using mapping information stored in the unit object.
Parameters: value : str or iterable
Value or list of values to be converted.
unit :
UnitDataAn object mapping strings to integers.
axis :
AxisThe axis on which the converted value is plotted.
Note
axis is unused.
Returns: mapped_value : float or ndarray[float]
-
static
-
class
matplotlib.category.StrCategoryFormatter(units_mapping)[source]¶ Bases:
matplotlib.ticker.FormatterString representation of the data at every tick.
Parameters: units_mapping : Dict[Str, int]
-
class
matplotlib.category.StrCategoryLocator(units_mapping)[source]¶ Bases:
matplotlib.ticker.LocatorTick at every integer mapping of the string data.
Parameters: units_mapping : Dict[str, int]