statsplotly.plot_specifiers.figure package

This subpackage defines objects and utility methods for figure properties.

pydantic model statsplotly.plot_specifiers.figure.HistogramPlot

Bases: BasePlot[HistogramSpecifier]

Fields:
  • plot_specifier (statsplotly.plot_specifiers.trace.HistogramSpecifier)

Validators:

field plot_specifier: HistogramSpecifier [Required]
classmethod initialize(fig: Figure | None, row: int, col: int, plot_specifier: HistogramSpecifier) Self

Initializes a subplot layout.

property central_tendency_col: int
property main_row: int

Returns the index of the main row in the subplot.

pydantic model statsplotly.plot_specifiers.figure.JointplotPlot

Bases: BasePlot[JointplotSpecifier]

Fields:
  • plot_specifier (statsplotly.plot_specifiers.trace.JointplotSpecifier)

Validators:

field plot_specifier: JointplotSpecifier [Required]
classmethod initialize(fig: Figure | None, row: int, col: int, plot_specifier: JointplotSpecifier) JointplotPlot

Initializes a subplot layout.

tidy_plot() JointplotPlot

Tidies up the jointplot figure layout.

We are limited to formatting only axes in the figure, as in the current implementation of jointplot, coloraxes are managed at the trace level instead of the layout level.

property main_row: int

Returns the index of the main row in the subplot.

class statsplotly.plot_specifiers.figure.SharedGridAxis(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)

Bases: StrEnum

ALL = 'all'
COLS = 'cols'
ROWS = 'rows'
pydantic model statsplotly.plot_specifiers.figure.SubplotGridFormatter

Bases: _SubplotGridValidator

Wraps a Plotly Figure with methods to format the subplot grid.

fig

A plotly.graph_objects.Figure with a subplot grid.

Fields:

Validators:

check_common_xaxes_ticks(col_idx: int) bool
check_common_yaxes_ticks(row_idx: int) bool
set_common_axis_limit(shared_grid_axis: Literal['cols', 'rows', 'all'] = 'all', plot_axis: Literal['xaxis', 'yaxis', 'coloraxis'] | None = None, common_range: bool = True, link_axes: bool = False) SubplotGridFormatter

Set common axis limits along a shared grid axis, optionally linking the axes.

Parameters:
  • shared_grid_axis – A SharedGridAxis value.

  • plot_axis

    A PlotAxis value.

  • common_range – If True (default), set a common range for the axes targeted by plot_axis.

  • link_axes – If True (default False), link the axes targeted by plot_axis.

Returns:

A SubplotGridFormatter instance.

set_common_coloraxis(shared_grid_axis: SharedGridAxis) SubplotGridFormatter

Set a common coloraxis along a shared grid axis.

Parameters:

shared_grid_axis – A SharedGridAxis value.

Returns:

A SubplotGridFormatter instance.

set_suplotgrid_titles(grid_axis: GridAxis) Callable[[...], Any]
tidy_axes() None

Removes titles and ticks of linked axes in a subplot grid.

tidy_subplots(title: str | None = None, no_legend: bool = False, row_titles: Sequence[str] | None = None, col_titles: Sequence[str] | None = None) SubplotGridFormatter

Tidy a subplot grid by removing redundant axis titles and optionally adding annotations.

Parameters:
  • title – A string for the figure title.

  • no_legend – If True, hides the legend.

  • row_titles – A list of string the size of the row dimension specifying a title for each row.

  • col_titles – A list of string the size of the column dimension specifying a title for each column.

Returns:

A SubplotGridFormatter instance.

statsplotly.plot_specifiers.figure.create_fig(fig: Figure | None, traces: dict[str, BaseTraceType], layout: HeatmapLayout | CategoricalLayout | ScatterLayout | SceneLayout | BarLayout | HistogramLayout, row: int | None, col: int | None, secondary_y: bool = False) Figure

Creates or updates a figure with the appropriate layout.