Colormap¶
-
Colormap(*args, name=None, listmode='perceptual', fade=None, cycle=None, shift=None, cut=None, left=None, right=None, reverse=False, save=False, save_kw=None, **kwargs)[source]¶ Generates or retrieves colormaps and optionally merges and manipulates them in a variety of ways; used to interpret the
cmapandcmap_kwarguments when passed to any plotting method wrapped bycmap_wrapper.- Parameters
*args (colormap-spec) – Positional arguments that individually generate colormaps. If more than one argument is passed, the resulting colormaps are merged. Arguments are interpreted as follows.
If
Colormapor a registered colormap name, the colormap is simply returned.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.fade (float, optional) – The maximum luminosity used when generating colormaps with
PerceptuallyUniformColormap.from_color. Default is100when callingColormapdirectly, and90whenColormapis called byCycle(this prevents having pure white in the color cycle).For example,
plot.Colormap('blue', fade=80)generates a blue colormap that fades to a pale blue with 80% luminance.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'when generating colormaps withPerceptuallyUniformColormap.from_color. Default is colors from the currently active property cycler.For example,
plot.Colormap('C0', 'C1', 'C2', cycle='538')generates a colormap using colors from the'538'color cycle.listmode ({‘perceptual’, ‘linear’, ‘listed’}, optional) – Controls how colormaps are generated when you input list(s) of colors. If
'perceptual', aPerceptuallyUniformColormapis generated withPerceptuallyUniformColormap.from_list. If'linear', aLinearSegmentedColormapis generated withfrom_list. If'listed', theListedColormapis generated.Default is
'perceptual'when callingColormapdirectly, and'listed'whenColormapis called byCycle.cut (float, optional) – Passed to
LinearSegmentedColormap.punched. This applies to the final merged colormap.left, right (float, optional) – Passed to
LinearSegmentedColormap.truncatedorListedColormap.truncated. These apply to each colormap individually.reverse (bool, optional) – Passed to
LinearSegmentedColormap.reversedorListedColormap.reversed. This applies to each colormap individually.shift (float, optional) – Passed to
LinearSegmentedColormap.shiftedorListedColormap.shifted. This applies to the final merged colormap.save (bool, optional) – Whether to call the colormap save method, i.e.
LinearSegmentedColormap.saveorListedColormap.save.save_kw (dict-like, optional) – Ignored if
saveisFalse. Passed to the colormap save method, i.e.LinearSegmentedColormap.saveorListedColormap.save.**kwargs – Passed to
LinearSegmentedColormap.concatenateorListedColormap.concatenate. Each of these functions accepts arbitrary colormap settings.
- Returns
Colormap– ALinearSegmentedColormaporListedColormapinstance.