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

colsstr, 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).
amountfloat
A value in [0.,1.] defining the degree of desaturation. amount = 1. removes all color, amount = 0. none, defaults to 1..

Return

list: Returns a list of (modified) hex colors.

Examples

from colorspace import palette, diverging_hcl, desaturate
from colorspace import specplot, swatchplot
from colorspace.colorlib import hexcols
cols = hexcols(diverging_hcl()(10))
specplot(desaturate(cols));

specplot(desaturate(cols, 0.5));

# Take a list of colors which can be interpreted/translated to hex
# colors and desaturate them via the HCL color space
cols = ["magenta", "red", "orange", "#F2F204", "#6BF204", "#4DA00D"]
desaturate(cols)
['#919191', '#7F7F7F', '#B8B8B8', '#EAEAEA', '#D5D5D5', '#8D8D8D']
swatchplot([cols, desaturate(cols)],
           show_names = False, figsize = (5, 1.5));

# Desaturate palette object (same colors as above)
pal = palette(cols, name = "custom palette")
desaturate(pal)
['#919191', '#7F7F7F', '#B8B8B8', '#EAEAEA', '#D5D5D5', '#8D8D8D']
# Desaturate a matplotlib cmap object
desaturate(pal.cmap())
custom palette
custom palette colormap
under
bad
over