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, and ListedColormap. Used to interpret the cmap and cmap_kw arguments when passed to any plotting method wrapped by cmap_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 or append. Arguments are interpreted as follows:

  • name (str, optional) – Name under which the final colormap is registered. It can then be reused by passing cmap='name' to plotting functions like contourf.

  • listmode ({‘perceptual’, ‘linear’, ‘listed’}, optional) – Controls how colormaps are generated when you input list(s) of colors. If 'perceptual', a PerceptuallyUniformColormap is generated with from_list. If 'linear', a LinearSegmentedColormap is generated with from_list. If 'listed', a ListedColormap is generated.

    Default is 'perceptual' when calling Colormap directly and 'listed' when Colormap is called by Cycle.

  • samples (int or list of int, optional) – For LinearSegmentedColormaps, this is used to generate ListedColormaps with to_listed. For ListedColormaps, this is used to updates the number of colors in the cycle. If samples 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 is 100 when calling Colormap directly, and 90 when Colormap is called by Cycle (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 a ListedColormap, we leave it alone, but when it is a LinearSegmentedColormap, we call to_listed with samples=10. This option is used when Cycle calls Colormap.

  • save (bool, optional) – Whether to call the colormap/color cycle save method, i.e. proplot.colors.LinearSegmentedColormap.save or proplot.colors.ListedColormap.save.

  • save_kw (dict-like, optional) – Ignored if save is False. Passed to the colormap/color cycle save method, i.e. proplot.colors.LinearSegmentedColormap.save or proplot.colors.ListedColormap.save.

Other Parameters

**kwargs – Passed to proplot.colors.LinearSegmentedColormap.copy, proplot.colors.PerceptuallyUniformColormap.copy, or proplot.colors.ListedColormap.copy.

Returns

Colormap – A LinearSegmentedColormap or ListedColormap instance.