Colormap¶
- Colormap(*args, name=None, listmode='perceptual', samples=None, cut=None, left=None, right=None, reverse=False, shift=None, fade=None, cycle=None, to_listed=False, save=False, save_kw=None, **kwargs)[source]¶
Generate, retrieve, modify, and/or merge instances of
PerceptuallyUniformColormap
,LinearSegmentedColormap
, andListedColormap
. Used to interpret thecmap
andcmap_kw
arguments when passed to any plotting method wrapped bycmap_changer
.- Parameters
*args (colormap-spec) – Positional arguments that individually generate colormaps. If more than one argument is passed, the resulting colormaps are merged with
append
orappend
. Arguments are interpreted as follows:If the argument is a
Colormap
or a registered colormap name, nothing more is done.If a filename string with valid extension, the colormap data will be loaded. See
register_cmaps
andregister_cycles
.If RGB tuple or color string, a
PerceptuallyUniformColormap
is generated withfrom_color
. If the string ends in'_r'
, the monochromatic map will be reversed, i.e. will go from dark to light instead of light to dark.If list of RGB tuples or color strings, a
PerceptuallyUniformColormap
is generated withfrom_list
.If dictionary containing the keys
'hue'
,'saturation'
, and'luminance'
, aPerceptuallyUniformColormap
is generated withfrom_hsl
.
name (str, optional) – Name under which the final colormap is registered. It can then be reused by passing
cmap='name'
to plotting functions likecontourf
.listmode ({‘perceptual’, ‘linear’, ‘listed’}, optional) – Controls how colormaps are generated when you input list(s) of colors. If
'perceptual'
, aPerceptuallyUniformColormap
is generated withfrom_list
. If'linear'
, aLinearSegmentedColormap
is generated withfrom_list
. If'listed'
, aListedColormap
is generated.Default is
'perceptual'
when callingColormap
directly and'listed'
whenColormap
is called byCycle
.samples (int or list of int, optional) – For
LinearSegmentedColormap
s, this is used to generateListedColormap
s withto_listed
. ForListedColormap
s, this is used to updates the number of colors in the cycle. Ifsamples
is integer, it applies to the final merged colormap. If it is a list of integers, it applies to each input colormap-spec individually.cut (float or list of float, optional) – Passed to
cut
. If float, this applies to the final merged colormap. If list of float, this applies to each input colormap-spec individually.left, right (float or list of float, optional) – Passed to
truncate
. If float, these apply to the final merged colormap. If list of float, these apply to each input colormap-spec individually.reverse (bool or list of bool, optional) – Passed to
reversed
. If float, this applies to the final merged colormap. If list of float, this applies to each input colormap-spec individually.shift (float or list of float, optional) – Passed to
shifted
. If float, this applies to the final merged colormap. If list of float, this applies to each input colormap-spec individually.fade (float or list of float, optional) – The maximum luminosity used when generating colormaps with
from_color
. Default is100
when callingColormap
directly, and90
whenColormap
is called byCycle
(this prevents having pure white in the color cycle).cycle (str or list of color-spec, optional) – The registered cycle name or a list of colors used to interpret cycle color strings like
'C0'
and'C2'
. Default is colors from the active property cycler.to_listed (bool, optional) – If
True
, when the final colormap is aListedColormap
, we leave it alone, but when it is aLinearSegmentedColormap
, we callto_listed
withsamples=10
. This option is used whenCycle
callsColormap
.save (bool, optional) – Whether to call the colormap/color cycle save method, i.e.
proplot.colors.LinearSegmentedColormap.save
orproplot.colors.ListedColormap.save
.save_kw (dict-like, optional) – Ignored if
save
isFalse
. Passed to the colormap/color cycle save method, i.e.proplot.colors.LinearSegmentedColormap.save
orproplot.colors.ListedColormap.save
.
- Other Parameters
**kwargs – Passed to
proplot.colors.LinearSegmentedColormap.copy
,proplot.colors.PerceptuallyUniformColormap.copy
, orproplot.colors.ListedColormap.copy
.- Returns
Colormap
– ALinearSegmentedColormap
orListedColormap
instance.