from colorspace import palette, diverging_hcl, desaturate
from colorspace import specplot, swatchplot
from colorspace.colorlib import hexcols
= hexcols(diverging_hcl()(10))
cols ; specplot(desaturate(cols))
Desaturate Colors by Chroma Removal in HCL Space
Description
Transform a vector of given colors to the corresponding colors with chroma reduced (by a tunable amount) in HCL space.
The color object (col
) is transformed to the HCL color space where the chroma is reduced, before converted back to the original color space.
See also: deutan, protan, tritan, desaturate, and cvd_image.
Usage
desaturate(cols, amount=1.0)
Arguments
-
cols
str, list, matplotlib.colors.LinearSegmentedColormap, colorobject
- Single hex color, list of hex colors (str), a matoplotlib cmap, or a color color object (such as RGB, hexcols, CIELUV).
-
amount
float
-
A value in
[0.,1.]
defining the degree of desaturation.amount = 1.
removes all color,amount = 0.
none, defaults to1.
.
Return
list
: Returns a list of (modified) hex colors.
Examples
0.5)); specplot(desaturate(cols,
# Take a list of colors which can be interpreted/translated to hex
# colors and desaturate them via the HCL color space
= ["magenta", "red", "orange", "#F2F204", "#6BF204", "#4DA00D"]
cols desaturate(cols)
['#919191', '#7F7F7F', '#B8B8B8', '#EAEAEA', '#D5D5D5', '#8D8D8D']
swatchplot([cols, desaturate(cols)],= False, figsize = (5, 1.5)); show_names
# Desaturate palette object (same colors as above)
= palette(cols, name = "custom palette")
pal desaturate(pal)
['#919191', '#7F7F7F', '#B8B8B8', '#EAEAEA', '#D5D5D5', '#8D8D8D']
# Desaturate a matplotlib cmap object
desaturate(pal.cmap())
custom palette
under
bad
over