layout#
API pages include interactive (HTML) plots that would possibly not render correctly on a mobile device.
- layout(plots: Sequence[Sequence[PlotSpec | SupPlotsSpec] | PlotSpec | SupPlotsSpec], *, widths: Sequence[float] | Sequence[Sequence[float]] | None = None, heights: Sequence[float] | None = None, hspace: float | None = None, vspace: float | None = None) SupPlotsSpec#
Arrange plots into a grid of rows, where each inner list is one row.
- Parameters:
plots (
Sequence[Sequence[PlotSpec | SupPlotsSpec] | PlotSpec | SupPlotsSpec]) – A sequence of rows. Each element is either a sequence of plots or a single plot, which is treated as a one-plot row.widths (
Sequence[float] | Sequence[Sequence[float]] | None, defaultNone) – Relative cell widths within each row. A nested sequence assigns widths per row (each inner length must match that row’s plot count). A flat sequence is broadcast to every row and is only valid when all rows have the same plot count. None distributes widths equally.heights (
Sequence[float] | None, defaultNone) – Relative row heights, one value per row. None distributes heights equally.hspace (
float | None, defaultNone) – Horizontal spacing between cells within a row, in pixels.vspace (
float | None, defaultNone) – Vertical spacing between rows, in pixels.
- Returns:
SupPlotsSpec– The composed grid.- Raises:
TypeError – If plots is not a nested sequence or widths is of an unexpected type.
ValueError – If any row is empty, or widths/heights lengths do not match the layout.
Notes
Unlike a uniform grid, rows may hold different numbers of plots. Each row is sized independently, so cells in different rows do not share column boundaries.
Examples
Arrange plots into ragged rows.
import scanpy as sc from ggrust import * import cellestial as cl data = cl.datasets.pbmc3k() first = cl.umap(data, key="CD14", axis_type="arrow") second = cl.tsne(data, key="MALAT1", axis_type="arrow") third = cl.umap(data, key="leiden", axis_type="arrow") cl.layout( [[first, second], third], widths=[[1, 2], [1]], heights=[1, 1], )