SubplotGrid#

class tollan.plot.plotly.SubplotGrid(subplots: list[~tollan.plot.plotly._Subplot] = <factory>, fig_layout: dict = <factory>)[source]#

Bases: object

A helper class to build multi panel figure.

Attributes Summary

fig_layout

grid

The grid specifications and subplot locations.

shape

The shape of the grid as (n_rows, n_cols).

subplots

Methods Summary

add_subplot(row, col[, fig, spec, ...])

Add figure to the subplots.

make_figure([fig_layout])

Create a figure composed from all subplots.

Attributes Documentation

fig_layout: dict = <dataclasses._MISSING_TYPE object>#
grid[source]#

The grid specifications and subplot locations.

Returns:

Grid array and list of (row_slice, col_slice, subplot) tuples

Return type:

tuple[Any, list[tuple[slice, slice, _Subplot]]]

shape#

The shape of the grid as (n_rows, n_cols).

Returns:

(n_rows, n_cols) dimensions of the subplot grid

Return type:

tuple[int, int]

subplots: list[_Subplot] = <dataclasses._MISSING_TYPE object>#

Methods Documentation

add_subplot(row: int, col: int, fig: Figure | None = None, spec: _SubplotSpec | None = None, row_height: float | None = None, col_width: float | None = None, title: str | None = None) None[source]#

Add figure to the subplots.

Parameters:
  • row (int) – Row index (1-based).

  • col (int) – Column index (1-based).

  • fig (go.Figure, optional) – Plotly figure to add to this subplot.

  • spec (dict, optional) – Subplot specification with type, rowspan, colspan.

  • row_height (float, optional) – Relative height of this row.

  • col_width (float, optional) – Relative width of this column.

  • title (str, optional) – Title for this subplot.

make_figure(fig_layout: dict[str, Any] | None = None, **kwargs: Any) Figure[source]#

Create a figure composed from all subplots.

Parameters:
  • fig_layout (dict, optional) – Layout dictionary to merge with default layout.

  • **kwargs (dict) – Additional arguments passed to make_subplots (e.g., shared_xaxes, shared_yaxes, horizontal_spacing, vertical_spacing).

Returns:

Plotly figure with all subplots arranged.

Return type:

go.Figure