# Create LinearSegmentedColormap from diverging_hcl() palette.
# By default, 256 distinct colors are used across the palette.
from colorspace import diverging_hcl, specplot
= diverging_hcl()
pal = pal.cmap()
cmap1 cmap1.N
256
Documentation built with Python 3.11.10
, pyp2qmd 0.1.1
and quarto 1.5.57
on GitHub.
Allows to retrieve a matplotlib LinearSegmentedColormap color map. Clasically LinearSegmentedColormaps allow to retrieve a set of N
colors from a set of n
colors where N >> n
. The matplotlib simply linearely interpolates between all n
colors to extend the number of colors to N
.
In case of hclpalette
objects this is not necessary as hclpalette
objects allow to retrieve N
colors directly along well-specified Hue-Chroma-Luminance paths. Thus, this method returns a matplotlib color map with n = N
colors. The linear interpolation between the colors (as typically done by LinearSegmentedColormap) is not necessary. However, for convenience cmaps have been implemented such that you can easily use hcl based palettes in your existing workflow.
sequential_hcl.cmap(n=256,
name='custom_hcl_cmap')
n
int
n = 256
name
str
custom_hcl_cmap
Returns a LinearSegmentedColormap
(cmap) to be used with the matplotlib library.
TypeError
: If n
is not int
ValueError
: If n
is lower than 2