to_rgb(color, space='rgb', cycle=None, alpha=False)[source]

Translate the color in any format and from any colorspace to an RGB tuple. This is a generalization of matplotlib.colors.to_rgb and the inverse of to_xyz.

  • 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 (see ColorDict).

    If space is 'rgb', this is a tuple of RGB values, and any channels are larger than 2, the channels are assumed to be on a 0 to 255 scale and are therefore divided by 255.

  • 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 used to interpret colors that look like 'C0', 'C1', etc. Default is rc.cycle = 'colorblind'.

  • alpha (bool, optional) – Whether to preserve the opacity channel, if it exists. Default is False.


color – The RGB tuple.