to_rgb¶
-
to_rgb
(color, space='rgb', cycle=None, alpha=False)[source]¶ Translate color in any format and from any colorspace to an RGB tuple. This is a generalization of
matplotlib.colors.to_rgb
and the inverse ofto_xyz
.- Parameters
color (str or length-3 list) – The color specification. Can be a tuple of channel values for the
space
colorspace, a hex string, a registered color name, a cycle color, or a colormap color (seeColorDict
).If
space
is'rgb'
, this is a tuple of RGB values, and any channels are larger than2
, the channels are assumed to be on a0
to255
scale and are therefore divided by255
.space ({‘rgb’, ‘hsv’, ‘hsl’, ‘hpl’, ‘hcl’}, optional) – The colorspace for the input channel values. Ignored unless
color
is an container of numbers.cycle (str or list, optional) – The registered color cycle name. Default is
rc.cycle
='colorblind'
. Ignored unlesscolor
is a color cycle string, e.g.'C0'
,'C1'
, …alpha (bool, optional) – Whether to preserve the opacity channel, if it exists. Default is
False
.
- Returns
color – The RGB tuple.