Color utilities#
- ridgeplot._colors.ColorScale#
A colorscale is an iterable of tuples of two elements:
the first element (a scale value) is a float bounded to the interval
[0, 1]the second element (a color) is a string representation of a color parsable by Plotly
For instance, the Viridis colorscale would be defined as
>>> get_colorscale("viridis") ((0.0, 'rgb(68, 1, 84)'), (0.1111111111111111, 'rgb(72, 40, 120)'), (0.2222222222222222, 'rgb(62, 73, 137)'), (0.3333333333333333, 'rgb(49, 104, 142)'), (0.4444444444444444, 'rgb(38, 130, 142)'), (0.5555555555555556, 'rgb(31, 158, 137)'), (0.6666666666666666, 'rgb(53, 183, 121)'), (0.7777777777777777, 'rgb(110, 206, 88)'), (0.8888888888888888, 'rgb(181, 222, 43)'), (1.0, 'rgb(253, 231, 37)'))
- ridgeplot._colors.validate_colorscale(colorscale)[source]#
Validate the structure, scale values, and colors of a colorscale.
Adapted from
_plotly_utils.colors.validate_colorscale().
- ridgeplot._colors._any_to_rgb(color)[source]#
Convert any color to an rgb string.
- Parameters:
color – A color. This can be a tuple of
(r, g, b)values, a hex string, or an rgb string.- Returns:
An rgb string.
- Return type:
- Raises:
TypeError – If
coloris not a tuple or a string.ValueError – If
coloris a string that does not represent a hex or rgb color.
- ridgeplot._colors.list_all_colorscale_names()[source]#
Get a list with all available colorscale names.
New in version 0.1.21: Replaces the deprecated
get_all_colorscale_names().- Returns:
A list with all available colorscale names.
- Return type:
list[str]
- ridgeplot._colors.get_all_colorscale_names()[source]#
Get a tuple with all available colorscale names.
Deprecated since version 0.1.21: Use
list_all_colorscale_names()instead.- Returns:
A tuple with all available colorscale names.
- Return type:
tuple[str,]
- ridgeplot._colors.get_colorscale(name)[source]#
Get a colorscale by name.
- Parameters:
name – The colorscale name. This argument is case-insensitive. For instance,
"YlOrRd"and"ylorrd"map to the same colorscale. Colorscale names ending in_rrepresent a reversed colorscale.- Returns:
A colorscale.
- Return type:
ColorScale- Raises:
ValueError – If an unknown name is provided