stanza.plotter.backends.utils

Shared utilities for plotting backends.

This module centralizes small, reusable helpers used by multiple plotting backends to keep implementations minimal and consistent.

Module Contents

Classes

NameDescription
PlotSpecPlot specification with type-safe fields.
PlotStateComplete plot state: source, figure, and spec in one place.

Functions

NameDescription
prepare_heatmap_dataCalculate rect sizes and update color range for heatmap data.
make_line_plotCreate a 1D line plot.
make_heatmap_plotCreate a 2D heatmap plot.

Data

LINE_PLOT_WIDTH LINE_PLOT_HEIGHT HEATMAP_WIDTH HEATMAP_HEIGHT

API

1stanza.plotter.backends.utils.LINE_PLOT_WIDTH

Value: 800

1stanza.plotter.backends.utils.LINE_PLOT_HEIGHT

Value: 400

1stanza.plotter.backends.utils.HEATMAP_WIDTH

Value: 800

1stanza.plotter.backends.utils.HEATMAP_HEIGHT

Value: 600

1class stanza.plotter.backends.utils.PlotSpec

Plot specification with type-safe fields.

1name: str

Value: None

1plot_type: str

Value: None

1x_label: str

Value: None

1y_label: str

Value: None

1z_label: str | None

Value: None

1cell_size: tuple[float, float] | None

Value: None

1mapper: bokeh.models.LinearColorMapper | None

Value: None

1dx: float | None

Value: None

1dy: float | None

Value: None

1value_min: float

Value: float(...)

1value_max: float

Value: float(...)

1class stanza.plotter.backends.utils.PlotState

Complete plot state: source, figure, and spec in one place.

Single source of truth for a plot’s data, visualization, and configuration. Ownership is clear: whoever has the PlotState owns the entire plot.

1source: bokeh.models.ColumnDataSource

Value: None

1figure: typing.Any

Value: None

1spec: stanza.plotter.backends.utils.PlotSpec

Value: None

1stanza.plotter.backends.utils.prepare_heatmap_data(
2 data: dict[str, typing.Any],
3 existing_data: dict[str, typing.Any],
4 spec: stanza.plotter.backends.utils.PlotSpec
5) -> dict[str, typing.Any]

Calculate rect sizes and update color range for heatmap data.

Parameters:

data
dict[str, typing.Any]

New data to add (x, y, value)

existing_data
dict[str, typing.Any]

Existing data in the data source

spec
stanza.plotter.backends.utils.PlotSpec

Plot specification with dx, dy, value_min, value_max

Returns:

Updated data with width and height fields added

1stanza.plotter.backends.utils.make_line_plot(
2 name: str,
3 x_label: str,
4 y_label: str
5) -> stanza.plotter.backends.utils.PlotState

Create a 1D line plot.

Returns complete PlotState with source, figure, and spec.

1stanza.plotter.backends.utils.make_heatmap_plot(
2 name: str,
3 x_label: str,
4 y_label: str,
5 z_label: str | None,
6 cell_size: tuple[float, float] | None
7) -> stanza.plotter.backends.utils.PlotState

Create a 2D heatmap plot.

Returns complete PlotState with source, figure, and spec.