from colorspace import rainbow_hcl, tritan, palette
from colorspace import specplot, swatchplot
# Drawing 100 colors along the HCL rainbow color palette
= rainbow_hcl()(100)
cols ; specplot(cols)
Simulate Color Vision Deficiency
Description
Transformation of R colors by simulating color vision deficiencies, based on a CVD transform matrix. This function is an interface to the CVD object and returns simulated colors for tritanope vision.
See also deutan, protan, desaturate, and cvd_image.
Usage
tritan(cols, severity=1.0, linear=True)
Arguments
-
cols
list, colorobject, matplotlib.colors.LinearSegmentedColormap
- Single hex color, list of hex colors (str), a matoplotlib cmap, or a color color object (such as RGB, hexcols, CIELUV).
-
severity
float
-
Severity in
[0., 1.]
. Zero means no deficiency, one maximum deficiency, defaults to1.
. -
linear
bool
-
Should the color vision deficiency transformation be applied to the linearised RGB coordinates (default)? If
False
, the transformation is applied to the gamma-corrected sRGB coordinates (as in the Machado et al. 2009 supplementary materials).
Return
colorobject
: Returns an object of the same type as the input object cols
with modified colors as people with tritanomaly see these colors (simulated).
Examples
; specplot(tritan(cols))
0.5)); specplot(tritan(cols,
# List of (hex) colors
= ["magenta", "red", "orange", "#F2F204", "#6BF204", "#4DA00D"]
cols ; tritan(cols)
# Visualize original and simulated color swatches
swatchplot([cols, tritan(cols)],= False, figsize = (5, 1.5)); show_names
# From palette object
= palette(cols, name = "custom palette")
pal tritan(pal)
['#FF4A97', '#FF000F', '#FF8E8D', '#FFE2CE', '#60E9CE', '#489A88']
# From cmap (returns cmap)
tritan(pal.cmap())
custom palette
under
bad
over