matplotlib.colors
#
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.
See also
Creating Colormaps in Matplotlib for examples of how to make colormaps and
Choosing Colormaps in Matplotlib for a list of built-in colormaps.
Colormap Normalization for more details about data normalization
More colormaps are available at palettable.
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#
|
A class which, when called, linearly normalizes data into the |
|
Dummy replacement for |
|
The inverse hyperbolic sine scale is approximately linear near the origin, but becomes logarithmic for larger positive or negative values. |
|
Generate a colormap index based on discrete intervals. |
|
Normalize symmetrical data around a center (0 by default). |
|
Arbitrary normalization using functions for the forward and inverse. |
|
Normalize a given value to the 0-1 range on a log scale. |
|
Linearly map a given value to the 0-1 range and then apply a power-law normalization over that range. |
|
The symmetrical logarithmic scale is logarithmic in both the positive and negative directions from the origin. |
|
Normalize data with a set center. |
Colormaps#
|
Baseclass for all scalar to RGBA mappings. |
|
Colormap objects based on lookup tables using linear segments. |
|
Colormap object generated from a list of colors. |
Other classes#
Container for sequences of colors that are known to Matplotlib by name. |
|
|
Create a light source coming from the specified azimuth and elevation. |
Functions#
|
A helper routine to generate a cmap and a norm instance which behave similar to contourf's levels and colors arguments. |
|
Convert hsv values to rgb. |
|
Convert float rgb values (in the range [0, 1]), in a numpy array to hsv values. |
|
Convert c to a hex color. |
|
Convert c to an RGB color, silently dropping the alpha channel. |
|
Convert c to an RGBA color. |
|
Convert c to a (n, 4) array of RGBA colors. |
Return whether c can be interpreted as an RGB(A) color. |
|
|
Return whether the colors c1 and c2 are the same. |
Return the global mapping of names to named colors. |
|
|
Decorator for building a |