ridgeplot._colors

Color utilities.

ridgeplot._colors.ColorScale

A colorscale is an iterable of tuples of two elements:

  1. the first element (a scale value) is a float bounded to the interval [0, 1]

  2. 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)'))

alias of Iterable[Tuple[float, str]]

ridgeplot._colors._Color

A color can be represented as an rgb(a) or hex string or a tuple of (r, g, b) values.

alias of str | Tuple[float, float, float]

ridgeplot._colors._colormap_loader()[source]
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:

str

Raises:
  • TypeError – If color is not a tuple or a string.

  • ValueError – If color is 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.

Added 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 _r represent a reversed colorscale.

Returns:

A colorscale.

Return type:

ColorScale

Raises:

ValueError – If an unknown name is provided

ridgeplot._colors.get_color(colorscale, midpoint)[source]

Get a color from a colorscale at a given midpoint.

Given a colorscale, it interpolates the expected color at a given midpoint, on a scale from 0 to 1.

ridgeplot._colors.apply_alpha(color, alpha)[source]