OnlinePlotBase

class OnlinePlotBase[source]

Bases: object

Class to handle creation and management of Matplotlib figures to monitor behavioral data in real-time.

Use this with the variables you are registering in your task, that are part of Task.session_df.

Subclasses should override create_figure_and_axes (to create axes) and update_plot (to draw on existing axes).

__init__() None[source]

Initializes the OnlinePlotBase instance.

Methods

__init__()

Initializes the OnlinePlotBase instance.

close()

Closes the matplotlib figure and resets the state.

create_figure_and_axes([width, height])

Creates the figure and axes.

ensure_figure([width, height])

Ensures that the matplotlib figure exists, creating it if necessary.

update_canvas(df)

Updates the plot with new data and redraws the canvas.

update_plot(df)

Updates the plot content.

ensure_figure(width: int = 10, height: int = 8) None[source]

Ensures that the matplotlib figure exists, creating it if necessary.

Parameters:
  • width (int, optional) – Width of the figure in inches. Defaults to 10.

  • height (int, optional) – Height of the figure in inches. Defaults to 8.

close() None[source]

Closes the matplotlib figure and resets the state.

update_canvas(df: pandas.DataFrame) None[source]

Updates the plot with new data and redraws the canvas.

Parameters:

df (pd.DataFrame) – The dataframe containing the latest session data.

create_figure_and_axes(width: int = 10, height: int = 8) None[source]

Creates the figure and axes. Should be overridden by subclasses.

Parameters:
  • width (int, optional) – Width of the figure. Defaults to 10.

  • height (int, optional) – Height of the figure. Defaults to 8.

update_plot(df: pandas.DataFrame) None[source]

Updates the plot content. Should be overridden by subclasses.

Parameters:

df (pd.DataFrame) – The dataframe containing the latest session data.