online_cpd_plotter

Online Change-Point Detection Plotter.

This module provides the OnlineCpdPlotter class that coordinates multiple visualizers and components to create comprehensive visualizations for change-point detection analysis.

class pysatl_cpd.analysis.visualization.online.plotters.online_cpd_plotter.OnlineCpdPlotter(backend, data_provider=None, detection_trace=None, layout=None)[source]

Bases: Generic

Coordinator class for online change-point detection visualizations.

This class manages visualizers and components to create comprehensive visualizations. It provides a simplified API for setting up visualizations with configurable defaults.

Parameters:
__init__(backend, data_provider=None, detection_trace=None, layout=None)[source]
Parameters:
Return type:

None

property backend: DrawBackend

Return the plotting backend used by this visualizer.

Returns:

Current backend (MATPLOTLIB or PLOTLY).

Return type:

DrawBackend

default_layout()[source]

Create figure and axes using the current layout strategy.

Returns:

Figure object and axes mapping for drawing.

Return type:

tuple[Figure | Figure, dict[str, Axes] | dict[str, tuple[int, int]]]

set_data_provider(data_provider)[source]

Set the data provider for the timeseries visualizer.

Parameters:

data_provider (DataProvider[Any, TimeseriesAnnotation]) – Data provider containing observations.

Returns:

Returns self to allow method chaining.

Return type:

Self

set_timeseries_visualizer(timeseries_visualizer)[source]

Replace the timeseries visualizer coordinated by this plotter.

Return type:

Self

Parameters:

timeseries_visualizer (ITimeseriesVisualizer[Any])

set_detection_trace(detection_trace)[source]

Set the detection trace for the trace visualizer.

Parameters:

detection_trace (OnlineDetectionTrace[TypeVar(StateT, bound= OnlineAlgorithmState)]) – Detection trace from online algorithm execution.

Returns:

Returns self to allow method chaining.

Return type:

Self

set_ground_truth(change_points, margin=0)[source]

Set ground truth change points and margin.

Parameters:
  • change_points (list[int]) – List of ground truth change point indices.

  • margin (int | tuple[int, int]) – Margin around change points. An integer creates a symmetric margin. A tuple (left, right) creates an asymmetric margin. If both values are 0, the margin is not drawn.

Returns:

Returns self to allow method chaining.

Return type:

Self

set_legend_axis(axis_name)[source]

Set the axis where legend should be displayed for detection components.

Parameters:

axis_name (str | None) – Name of the axis for legend display. None means auto (timeseries).

Returns:

Returns self to allow method chaining.

Return type:

Self

add_component(name, component, axes_names, show_legend=True)[source]

Add a visual component to the plotter.

Parameters:
  • name (str) – Name to identify the component.

  • component (IVisualComponent) – Component instance to add.

  • axes_names (list[str]) – Names of axes where the component should be drawn. Must be provided.

  • show_legend (bool) – Whether to show legend for this component.

Returns:

Returns self to allow method chaining.

Return type:

Self

remove_component(name)[source]

Remove a component from the plotter.

Parameters:

name (str) – Name of the component to remove.

Returns:

Returns self to allow method chaining.

Return type:

Self

get_component(name)[source]

Get a component by name.

Parameters:

name (str) – Name of the component to retrieve.

Returns:

The component instance or None if not found.

Return type:

IVisualComponent | None

draw(figure, axes)[source]

Coordinate drawing of all visualizers and components.

Parameters:
  • figure (Figure | Figure) – The figure to draw on (Matplotlib or Plotly).

  • axes (dict[str, Axes] | dict[str, tuple[int, int]]) – Mapping from subplot names to their axes objects or positions.

Returns:

The modified figure with all visual elements drawn.

Return type:

Figure | Figure

property required_axes: set[str]

Return the set of all axes names required by visualizers and components.

Returns:

Set of subplot names needed for drawing.

Return type:

set[str]

set_layout(layout)[source]

Set the layout strategy for this plotter.

Parameters:

layout (ILayoutStrategy | str) –

Layout strategy to use. Can be:

  • An ILayoutStrategy instance

  • One of: “vertical”, “split”, “dashboard-lite”, “dashboard”

Returns:

Returns self to allow method chaining.

Return type:

Self