PerceptuallyUniformColormap

class PerceptuallyUniformColormap(name, segmentdata, N=None, space=None, clip=True, gamma=None, gamma1=None, gamma2=None, **kwargs)[source]

Bases: proplot.colors.LinearSegmentedColormap, proplot.colors._Colormap

Similar to LinearSegmentedColormap, but instead of varying the RGB channels, we vary hue, saturation, and luminance in either the HCL colorspace or the HSL or HPL scalings of HCL.

Parameters
  • name (str) – The colormap name.

  • segmentdata (dict-like) – Dictionary containing the keys 'hue', 'saturation', 'luminance', and (optionally) 'alpha'. The key 'chroma' is treated as a synonym for 'saturation'. The shorthands 'h', 's', 'l', 'a', and 'c' are also acceptable. The key values can be callable functions that return channel values given a colormap index, or 3-column arrays indicating the coordinates and channel transitions. See LinearSegmentedColormap for a more detailed explanation.

  • space ({‘hsl’, ‘hpl’, ‘hcl’}, optional) – The hue, saturation, luminance-style colorspace to use for interpreting the channels. See this page for a description.

  • clip (bool, optional) – Whether to “clip” impossible colors, i.e. truncate HCL colors with RGB channels with values >1, or mask them out as gray.

  • alpha (float, optional) – The opacity for the entire colormap. This overrides the input segment data.

  • cyclic (bool, optional) – Whether the colormap is cyclic. If True, this changes how the leftmost and rightmost color levels are selected, and extend can only be 'neither' (a warning will be issued otherwise).

  • gamma (float, optional) – Sets gamma1 and gamma2 to this identical value.

  • gamma1 (float, optional) – If >1, makes low saturation colors more prominent. If <1, makes high saturation colors more prominent. Similar to the HCLWizard option.

  • gamma2 (float, optional) – If >1, makes high luminance colors more prominent. If <1, makes low luminance colors more prominent. Similar to the HCLWizard option.

Other Parameters

**kwargs – Passed to LinearSegmentedColormap.

Example

The below example generates a PerceptuallyUniformColormap from a segmentdata dictionary that uses color names for the hue data, instead of channel values between 0 and 360.

>>> import proplot as pplt
>>> data = {
>>>     'h': [[0, 'red', 'red'], [1, 'blue', 'blue']],
>>>     's': [[0, 100, 100], [1, 100, 100]],
>>>     'l': [[0, 100, 100], [1, 20, 20]],
>>> }
>>> cmap = pplt.PerceptuallyUniformColormap(data)

Methods Summary

copy([name, segmentdata, N, alpha, gamma, …])

Return a new colormap with relevant properties copied from this one if they were not provided as keyword arguments.

from_color(name, color, *[, space])

Return a simple monochromatic “sequential” colormap that blends from white or near-white to the input color.

from_hsl(name, *[, ratios])

Make a PerceptuallyUniformColormap by specifying the hue, saturation, and luminance transitions individually.

from_list(name, colors[, ratios])

Make a PerceptuallyUniformColormap from a list of colors.

set_gamma([gamma, gamma1, gamma2])

Modify the gamma value(s) and refresh the lookup table.

to_linear_segmented([name])

Convert the PerceptuallyUniformColormap to a standard LinearSegmentedColormap.