PerceptualColormap¶
- class PerceptualColormap(*args, space=None, clip=True, gamma=None, gamma1=None, gamma2=None, **kwargs)[source]¶
Bases:
proplot.colors.ContinuousColormap
A
ContinuousColormap
with linear transitions across hue, saturation, and luminance rather than red, blue, and green.- Parameters
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. SeeLinearSegmentedColormap
for a more detailed explanation.name (
str
, optional) – The colormap name. This can also be passed as the first positional string argument. Default is'_no_name'
.N (
int
, optional) – Number of points in the colormap lookup table. Default isrc['image.lut']
=256
.space (
{'hsl', 'hpl', 'hcl', 'hsv'}
, optional) – The hue, saturation, luminance-style colorspace to use for interpreting the channels. See this page for a full description. Default is'hsl'
.clip (
bool
, optional) – Whether to “clip” impossible colors (i.e. truncate HCL colors with RGB channels with values greater than 1) or mask them out as gray.gamma (
float
, optional) – Setgamma1
andgamma2
to this identical value.gamma1 (
float
, optional) – If greater than 1, make low saturation colors more prominent. If less than 1, make high saturation colors more prominent. Similar to the HCLWizard option.gamma2 (
float
, optional) – If greater than 1, make high luminance colors more prominent. If less than 1, make low luminance colors more prominent. Similar to the HCLWizard option.alpha (
float
, optional) – The opacity for the entire colormap. This overrides the input opacities.cyclic (
bool
, optional) – Whether the colormap is cyclic. IfTrue
, this changes how the leftmost and rightmost color levels are selected, andextend
can only be'neither'
(a warning will be issued otherwise).
- Other Parameters
**kwargs – Passed to
matploitlib.colors.LinearSegmentedColormap
.
Example
The below example generates a
PerceptualColormap
from asegmentdata
dictionary that uses color names for the hue data, instead of channel values between0
and360
.>>> 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.PerceptualColormap(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
(*args, **kwargs)Return a simple monochromatic "sequential" colormap that blends from white or near-white to the input color.
from_hsl
(*args, **kwargs)Make a
PerceptualColormap
by specifying the hue, saturation, and luminance transitions individually.from_list
(*args[, adjust_grays])Make a
PerceptualColormap
from a sequence of colors.set_gamma
([gamma, gamma1, gamma2])Set the gamma value(s) for the luminance and saturation transitions.
to_continuous
([name])Convert the
PerceptualColormap
to a standardContinuousColormap
.