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_rgband the inverse ofto_xyz.- Parameters
color (str or length-3 list) – The color specification. Can be a tuple of channel values for the
spacecolorspace, a hex string, a registered color name, a cycle color, or a colormap color (seeColorCacheDict).If
spaceis'rgb', this is a tuple of RGB values, and any channels are larger than2, the channels are assumed to be on a0to255scale and are therefore divided by255.space ({‘rgb’, ‘hsv’, ‘hpl’, ‘hsl’, ‘hcl’}, optional) – The colorspace for the input channel values. Ignored unless
coloris an container of numbers.cycle (str or list, optional) – The registered color cycle name. Default is
rc.cycle='colorblind'. Ignored unlesscoloris 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.