from colorspace import rainbow
= rainbow()
pal 10) pal.colors(
['#FF0000',
'#FF9900',
'#CCFF00',
'#33FF00',
'#00FF66',
'#00FFFF',
'#0066FF',
'#3300FF',
'#CC00FF',
'#FF0099']
Documentation built with Python 3.11.10
, pyp2qmd 0.1.1
and quarto 1.5.57
on GitHub.
Implements the (in-)famous rainbow (or jet) color palette that was used very frequently in many software packages but has been widely criticized for its many perceptual problems. It is specified by a start
and end
hue \(\in [0.-1.]\) with red = 0
, yellow = 1/6
, green = 2/6
, cyan = 3/6
, blue = 4/6
, and magenta = 5/6
. However, these are very flashy and unbalanced with respect to both chroma and luminance which can lead to various optical illusions. Also, the hues that are equispaced in RGB space tend to cluster at the red, green, and blue primaries. Therefore, it is recommended to use a suitable palette from hcl.colors
instead of rainbow
.
start
and/or end
both allow for lambda functions with one single argument n
(number of colors), see examples.
See also: qualitative_hcl, sequential_hcl, diverging_hcl, divergingx_hcl, rainbow_hcl, heat_hcl, terrain_hcl, and diverging_hsv.
rainbow(s=1, v=1, start=0,
end=<function rainbow.<lambda>>,
rev=False, *args, **kwargs)
s
float, int
[0., 1.]
. Defaults to 1.0
.
v
float, int
[0., 1.]
. Defaults to 1.0
.
start
float, int, function
[0., 1.]
at which the rainbow begins. Defaults to 0.
. Can be a function with one input n
(number of colors). If outside [0., 1.]
it will be wrapped.
end
float, int, function
[0., 1.]
at which the rainbow ends. Defaults to 0.
. Can be a function with one input n
(number of colors). If outside [0., 1.]
it will be wrapped.
rev
bool
*args
**kwargs
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.
rainbow.cmap(n=256, name='custom_hcl_cmap')
rainbow.colors(n=11, alpha=None, **kwargs)
rainbow.get(key)
rainbow.hclplot(n=7, **kwargs)
rainbow.name()
rainbow.show_settings()
rainbow.specplot(n=180, *args, **kwargs)
rainbow.swatchplot(n=7, **kwargs)
['#FF0000',
'#FF9900',
'#CCFF00',
'#33FF00',
'#00FF66',
'#00FFFF',
'#0066FF',
'#3300FF',
'#CC00FF',
'#FF0099']
['#FF0000',
'#FF9900',
'#CCFF00',
'#33FF00',
'#00FF66',
'#00FFFF',
'#0066FF',
'#3300FF',
'#CC00FF',
'#FF0099']
TypeError
: If s
or v
are not float or int.
ValueError
: If s
or v
are outside range, must be in [0., 1.]
.
TypeError
: If start
and end
are not float/int in [0., 1.]
or lambda functions.
TypeError
: If rev
is not bool.