from colorspace import divergingx_hcl
pal1 = divergingx_hcl()
pal1.colors(5)['#008585', '#9BBAA0', '#FBF2C4', '#DEA868', '#C7522B']
Documentation built with Python 3.11.10, pyp2qmd 0.1.1 and quarto 1.5.57 on GitHub.
More flexible version of the diverging_hcl class. A diverging X palette basically consists of two multi-hue sequential palettes.
The divergingx_hcl function simply calls sequential_hcl twice with a prespecified set of hue, chroma, and luminance parameters. This is similar to diverging_hcl but allows for more flexibility: diverging_hcl employs two single-hue sequential palettes, always uses zero chroma for the neutral/central color, and restricts the chroma/luminance path to be the same in both “arms” of the palette. In contrast, divergingx_hcl relaxes this to two full multi-hue palettes that can thus go through a non-gray neutral color (typically light yellow). Consequently, the chroma/luminance paths can be rather unbalanced between the two arms.
With this additional flexibility various diverging palettes suggested by https://ColorBrewer2.org/ and CARTO (https://carto.com/carto-colors/), can be emulated along with the Zissou 1 palette from ‘wesanderson’, Cividis from ‘viridis’, and Roma from ‘scico’.
If h is str it will overwrite the palette argument. In this case, pre-specified palette settings will be loaded but are allowed to be overwritten by the user. At any time the user can overwrite any of the settings.
See also: qualitative_hcl, sequential_hcl, diverging_hcl, rainbow_hcl, heat_hcl, terrain_hcl, diverging_hsv, and rainbow.
divergingx_hcl(h=[192, 77, 21], c=[40, 35, 100],
l=[50, 95, 50],
power=[1.0, 1.0, 1.2, 1.0], cmax=20,
fixup=True, palette=None, rev=False,
*args, **kwargs)
hlist
h is a str this argument acts like the palette argument (see palette input parameter).
clist
c1 and c3 while the second one is used for c2 (center value). When three values are provided they are used as c1, c2, and c3 (see also cmax).
llist
l1 and l3 while the second one is used for l2 (center value). When three are provided they are used as l1, l2, and l3 respectively.
powerlist
power[0] will be used for p1 and p4 while power[1] is used for p2 and p3 (symmetric). A list of length four allows to specify p1, p2, p3, and p4 individually. List of length three acts like a list of length two, the last element is ignored.
cmaxNone, float, int, list, numpy.ndarray
Non. If one value is provided it is used for cmax1, if two values are provided they are used as cmax1 and cmax2, respectively.
fixupbool
palettestr
revbool
*args
**kwargs
h1, h2, h3, c1, cmax1, c2, cmax2 c3, l1, l2, l3, p1, p2, p3, p4.
Initialize new object, no return. Raises a set of errors if the parameters are misspecified. Note that the object is callable, the default object call can be used to return hex colors (identical to the .colors() method), see examples.
divergingx_hcl.cmap(n=256, name='custom_hcl_cmap')
divergingx_hcl.colors(n=11, fixup=None, alpha=None, **kwargs)
divergingx_hcl.get(key)
divergingx_hcl.hclplot(n=7, **kwargs)
divergingx_hcl.name()
divergingx_hcl.show_settings()
divergingx_hcl.specplot(n=180, *args, **kwargs)
divergingx_hcl.swatchplot(n=7, **kwargs)
['#008585', '#9BBAA0', '#FBF2C4', '#DEA868', '#C7522B']
['#D66982', '#DF94A3', '#EEBEC7', '#FFF2F7', '#F3C3B2', '#BEA062', '#798233']
['#3C5941', '#FBF2C4', '#C7522B']
# Manual palette with user settings. The following diverginx
# palette goes from h = 180 (left) to h = 100 (center) and h = 20 (right).
# Croma is c = 30 (left), c = 5 (center), and c = 30 (right).
# In addition, both 'arms' have a maximum chroma of cmax = 70
# in the center of each of the two arms.
pal3 = divergingx_hcl(h = [180, 100, 20],
c = [30, 5, 30],
cmax = [70, 70])
pal3.specplot();
# Available default palettes (divergingx_hcl palettes)
from colorspace import divergingx_hcl, swatchplot, palette
carto = ["ArmyRose", "Earth", "Fall",
"Geyser", "TealRose", "Temps"]
brewer = ["PuOr", "RdBu", "RdGy", "PiYG", "PRGn",
"BrBG", "RdYlBu", "RdYlGn", "Spectral"]
others = ["Zissou 1", "Cividis", "Roma"]
# Create named palettes for swatchplot
col_carto = [palette(divergingx_hcl(x)(11), name = x) for x in carto]
col_brewer = [palette(divergingx_hcl(x)(11), name = x) for x in carto]
col_others = [palette(divergingx_hcl(x)(11), name = x) for x in others]
# Visualize available divergingx palettes
swatchplot({"Carto": col_carto,
"Brewer": col_brewer,
"Others": col_others},
figsize = (5.5, 6));
TypeError: If fixup is not bool.
TypeError: If palette is not None or str.
TypeError: If cmax not Non, float, int, list, numpy.ndarray.
ValueError: If cmax is list of length <1 or >2.
ValueError: If h, c, l, power, cmax contain unexpected types or values.
ValueError: If palette is string, but palette with this name cannot be found.
Exception: If h3 is not specified.
ValueError: If **kwargs are provides which are not among the allowed ones.