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. Default is rc.cycle = 'colorblind'. Ignored unless color is a color cycle string, e.g. 'C0', 'C1', …

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


color – The RGB tuple.