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 thecmapandcmap_kwarguments 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
appendorappend. Arguments are interpreted as follows:If the argument is a
Colormapor a registered colormap name, nothing more is done.If a filename string with valid extension, the colormap data will be loaded. See
register_cmapsandregister_cycles.If RGB tuple or color string, a
PerceptuallyUniformColormapis 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
PerceptuallyUniformColormapis generated withfrom_list.If dictionary containing the keys
'hue','saturation', and'luminance', aPerceptuallyUniformColormapis 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', aPerceptuallyUniformColormapis generated withfrom_list. If'linear', aLinearSegmentedColormapis generated withfrom_list. If'listed', aListedColormapis generated.Default is
'perceptual'when callingColormapdirectly and'listed'whenColormapis called byCycle.samples (int or list of int, optional) – For
LinearSegmentedColormaps, this is used to generateListedColormaps withto_listed. ForListedColormaps, this is used to updates the number of colors in the cycle. Ifsamplesis 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 is100when callingColormapdirectly, and90whenColormapis 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_listedwithsamples=10. This option is used whenCyclecallsColormap.save (bool, optional) – Whether to call the colormap/color cycle save method, i.e.
proplot.colors.LinearSegmentedColormap.saveorproplot.colors.ListedColormap.save.save_kw (dict-like, optional) – Ignored if
saveisFalse. Passed to the colormap/color cycle save method, i.e.proplot.colors.LinearSegmentedColormap.saveorproplot.colors.ListedColormap.save.
- Other Parameters
**kwargs – Passed to
proplot.colors.LinearSegmentedColormap.copy,proplot.colors.PerceptuallyUniformColormap.copy, orproplot.colors.ListedColormap.copy.- Returns
Colormap– ALinearSegmentedColormaporListedColormapinstance.