online_plot_base

Classes

OnlinePlotBase()

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

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).

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.