ridgeplot._color.interpolation module

Color interpolation utilities.

ridgeplot._color.interpolation.interpolate_color(colorscale, p)[source]

Get a color from a colorscale at a given interpolation point p.

This function always returns a color in the RGB format, even if the input colorscale contains colors in other formats.

ridgeplot._color.interpolation.slice_colorscale(colorscale, p_lower, p_upper)[source]

Slice a continuous colorscale between two intermediate points.

Parameters:
  • colorscale – The continuous colorscale to slice.

  • p_lower – The lower bound of the slicing interval. Must be >= 0 and < p_upper.

  • p_upper – The upper bound of the slicing interval. Must be <= 1 and > p_lower.

Returns:

The sliced colorscale.

Return type:

ColorScale

Raises:

ValueError – If p_lower is >= p_upper, or if either p_lower or p_upper are outside the range [0, 1].

ridgeplot._color.interpolation.ColorscaleInterpolants

A ColorscaleInterpolants contains the interpolants for a ColorScale.

Example

>>> interpolants: ColorscaleInterpolants = [
...     [0.2, 0.5, 1],
...     [0.3, 0.7],
... ]
class ridgeplot._color.interpolation.InterpolationContext(densities, n_rows, n_traces, x_min, x_max)[source]

Bases: object

Context information needed by the interpolation functions.

densities: Densities
n_rows: int
n_traces: int
x_min: Numeric
x_max: Numeric
classmethod from_densities(densities)[source]
protocol ridgeplot._color.interpolation.InterpolationFunc[source]

Bases: Protocol

Classes that implement this protocol must have the following methods / attributes:

__call__(ctx)[source]

Call self as a function.

ridgeplot._color.interpolation._mul(a, b)[source]

Multiply two tuples element-wise.

ridgeplot._color.interpolation._interpolate_row_index(ctx)[source]
ridgeplot._color.interpolation._interpolate_trace_index(ctx)[source]
ridgeplot._color.interpolation._interpolate_trace_index_row_wise(ctx)[source]
ridgeplot._color.interpolation._interpolate_mean_minmax(ctx)[source]
ridgeplot._color.interpolation._interpolate_mean_means(ctx)[source]
ridgeplot._color.interpolation.SolidColormode

See ridgeplot.ridgeplot.colormode for more information.

alias of Literal[‘row-index’, ‘trace-index’, ‘trace-index-row-wise’, ‘mean-minmax’, ‘mean-means’]

ridgeplot._color.interpolation.compute_solid_colors(colorscale, colormode, opacity, interpolation_ctx)[source]

Compute the solid colors for all traces in the plot.