Note
The Color tutorials and examples demonstrate how to set colors and colormaps. You may want to read those instead.
A module for converting numbers or color arguments to RGB or RGBA.
RGB and RGBA are sequences of, respectively, 3 or 4 floats in the range 0-1.
This module includes functions and classes for color specification conversions, and for mapping numbers to colors in a 1-D array of colors called a colormap.
Mapping data onto colors using a colormap typically involves two steps: a data
array is first mapped onto the range 0-1 using a subclass of Normalize,
then this number is mapped to a color using a subclass of Colormap. Two
subclasses of Colormap provided here: LinearSegmentedColormap, which uses
piecewise-linear interpolation to define colormaps, and ListedColormap, which
makes a colormap from a list of colors.
The module also provides functions for checking whether an object can be
interpreted as a color (is_color_like), for converting such an object
to an RGBA tuple (to_rgba) or to an HTML-like hex string in the
"#rrggbb" format (to_hex), and a sequence of colors to an (n, 4)
RGBA array (to_rgba_array). Caching is used for efficiency.
Colors that Matplotlib recognizes are listed at Specifying colors.
Color norms#
Univariate Colormaps#
Multivariate Colormaps#
Other classes#
Functions#
Exported colors#
The data used to populate the List of named colors are exposed as dictionaries that map color names to hex strings.
- matplotlib.colors.BASE_COLORS#
- matplotlib.colors.TABLEAU_COLORS#
- matplotlib.colors.CSS4_COLORS#
- matplotlib.colors.XKCD_COLORS#