to_rgb¶
- to_rgb(color, space='rgb', cycle=None)[source]¶
Translate the color from an arbitrary colorspace to an RGB tuple. This is a generalization of
matplotlib.colors.to_rgb
and the inverse ofto_xyz
.- Parameters
color (
color-spec
) – The color. Can be a 3-tuple or 4-tuple of channel values, a hex string, a registered color name, a cycle color like'C0'
, or a 2-tuple colormap coordinate specification like('magma', 0.5)
(seeColorDatabase
for details).If
space
is'rgb'
, this is a tuple of RGB values, and any channels are larger than2
, the channels are assumed to be on the0
to255
scale and are divided by255
.space (
{'rgb', 'hsv', 'hcl', 'hpl', 'hsl'}
, optional) – The colorspace for the input channel values. Ignored unlesscolor
is a tuple of numbers.cycle (
str
, optional) – The registered color cycle name used to interpret colors that look like'C0'
,'C1'
, etc. Default isrc.cycle
='colorblind'
.clip (
bool
, optional) – Whether to clip channel values into the valid0
to1
range. Default isTrue
.
- Returns
color (
3-tuple
) – An RGB tuple.