Figure factory#

ridgeplot._figure_factory.LabelsArray#

A LabelsArray represents the labels of traces in a ridgeplot.

For instance, the following is a valid LabelsArray:

>>> labels_array: LabelsArray = [
...     ["trace 1", "trace 2", "trace 3"],
...     ["trace 4", "trace 5"],
... ]

alias of Collection[Collection[str]]

ridgeplot._figure_factory.ShallowLabelsArray#

Shallow type for LabelsArray.

Example:

>>> labels_array: ShallowLabelsArray = ["trace 1", "trace 2", "trace 3"]

alias of Collection[str]

ridgeplot._figure_factory.ColorsArray#

A ColorsArray represents the colors of traces in a ridgeplot.

For instance, the following is a valid ColorsArray:

>>> colors_array: ColorsArray = [
...     ["red", "blue", "green"],
...     ["orange", "purple"],
... ]

alias of Collection[Collection[str]]

ridgeplot._figure_factory.ShallowColorsArray#

Shallow type for ColorsArray.

Example:

>>> colors_array: ShallowColorsArray = ["red", "blue", "green"]

alias of Collection[str]

ridgeplot._figure_factory.MidpointsArray#

A MidpointsArray represents the midpoints of colorscales in a ridgeplot.

For instance, the following is a valid MidpointsArray:

>>> midpoints_array: MidpointsArray = [
...     [0.2, 0.5, 1],
...     [0.3, 0.7],
... ]

alias of Collection[Collection[float]]

ridgeplot._figure_factory.get_xy_extrema(densities)[source]#

Get the global x-y extrema (x_min, x_max, y_min, y_max) from all the Densities array.

Parameters:

densities – A Densities array.

Returns:

A tuple of the form (x_min, x_max, y_min, y_max).

Return type:

Tuple[Numeric, Numeric, Numeric, Numeric]

Examples

>>> get_xy_extrema(
...     [
...         [
...             [(0, 0), (1, 1), (2, 2), (3, 3)],
...             [(0, 0), (1, 1), (2, 2)],
...             [(0, 0), (1, 1), (2, 2), (3, 3), (4, 4)],
...         ],
...         [
...             [(-2, 2), (-1, 1), (0, 1)],
...             [(2, 2), (3, 1), (4, 1)],
...         ],
...     ]
... )
(-2, 4, 0, 4)
ridgeplot._figure_factory._mul(a, b)[source]#

Multiply two tuples element-wise.

class ridgeplot._figure_factory.RidgePlotFigureFactory(densities, colorscale, coloralpha, colormode, labels, linewidth, spacing, show_yticklabels, xpad)[source]#

Refer to ridgeplot.ridgeplot().

property colormode_maps: Dict[str, Callable[[], MidpointsArray]]#
draw_base(x, y_shifted)[source]#

Draw the base for a density trace.

Adds an invisible trace at constant y that will serve as the fill-limit for the corresponding density trace.

draw_density_trace(x, y, y_shifted, label, color)[source]#

Draw a density trace.

Adds a density ‘trace’ to the Figure. The fill="tonexty" option fills the trace until the previously drawn trace (see draw_base()). This is why the base trace must be drawn first.

update_layout(y_ticks)[source]#

Update figure’s layout.

_compute_midpoints_row_index()[source]#

colormode=’row-index’

Uses the row’s index. e.g. if the ridgeplot has 3 rows of traces, then the midpoints will be [[1, …], [0.5, …], [0, …]].

_compute_midpoints_trace_index()[source]#

colormode=’trace-index’

Uses the trace’s index. e.g. if the ridgeplot has a total of 3 traces (across all rows), then the midpoints will be 0, 0.5, and 1, respectively.

_compute_midpoints_mean_minmax()[source]#

colormode=’mean-minmax’

Uses the min-max normalized (weighted) mean of each density to calculate the midpoints. The normalization min and max values are the minimum and maximum x-values from all densities, respectively.

_compute_midpoints_mean_means()[source]#

colormode=’mean-means’

Uses the min-max normalized (weighted) mean of each density to calculate the midpoints. The normalization min and max values are the minimum and maximum mean values from all densities, respectively.

pre_compute_colors()[source]#
make_figure()[source]#