pynaviz.base_plot.PlotTsdFrame#

class pynaviz.base_plot.PlotTsdFrame(data, index=None, parent=None, window_size=None, display_mode='lines', background='black')[source]#

Bases: _BasePlot

Visualization of a multi-column pynapple time series (nap.TsdFrame).

Supports three display modes toggled at runtime:

  • lines (default): each column rendered as a line with vertex colors.

  • image: all columns as a heatmap texture.

  • x_vs_y: one column plotted against another with a time marker.

Parameters:
  • data (nap.TsdFrame) – The column-based time series data.

  • index (int, optional) – Controller ID for synchronizing with other plots.

  • parent (optional) – GUI parent widget (e.g. QWidget).

  • window_size (float, optional) – Streaming window duration in seconds. If None, computed to fit up to 256 MB of memory.

  • display_mode (str, default "lines") – Initial display mode (“lines” or “image”). Toggle with the “m” key.

  • background (str or tuple, optional) – Background color (e.g. "white", "black", "#272822").

__init__(data, index=None, parent=None, window_size=None, display_mode='lines', background='black')[source]#
Parameters:
  • data (TsdFrame)

  • index (int | None)

  • parent (Any | None)

  • window_size (float | None)

  • display_mode (str)

  • background (str | None)

Methods

__init__(data[, index, parent, window_size, ...])

add_interval_sets(epochs[, colors, alpha, ...])

animate()

Updates the positions of rulers and reference lines based on the current world coordinate bounds and triggers a re-render of the scene.

close()

color_by(metadata_name[, cmap_name, vmin, vmax])

Apply color mapping to channels based on a metadata field.

from_state(state, available_vars)

Restore the full plot state from a previously saved dict.

get_plot_state()

Return the current display mode and its serializable state.

get_state()

Return the full serializable state of this plot.

group_by(metadata_name, **kwargs)

Group channels vertically by a metadata field.

jump_to_next_epoch()

Jump to the start of the next superposed epoch (across all added interval sets).

jump_to_previous_epoch()

Jump to the start of the previous superposed epoch (across all added interval sets).

plot_x_vs_y(x_col, y_col[, color, ...])

Plot one column versus another with a time-point marker.

remove_interval_set(label)

Remove an interval set from the plot.

set_plot_state(state[, available_vars])

Restore display mode and mode-specific state.

show()

To show the canvas in case of GLFW context used

sort_by(metadata_name[, mode])

Sort channels vertically by a metadata field.

update_interval_set(name, colors, alpha)

Update the color and transparency of an existing interval set.

Attributes

cmap

data

graphic

The active pygfx graphic, delegated to the current display mode.

add_interval_sets(epochs, colors=None, alpha=None, labels=None)#
Parameters:
animate()#

Updates the positions of rulers and reference lines based on the current world coordinate bounds and triggers a re-render of the scene.

This method performs the following: - Computes the visible world coordinate bounds. - Updates the horizontal (x) and vertical (y) rulers accordingly. - Repositions the center time reference line in the scene. - Re-renders the scene using the current camera and canvas settings.

Notes

This method should be called whenever the visible region of the plot changes (e.g., after zooming, panning, or resizing the canvas).

close()#
property cmap#
color_by(metadata_name, cmap_name='viridis', vmin=0.0, vmax=100.0)[source]#

Apply color mapping to channels based on a metadata field.

Parameters:
  • metadata_name (str) – Metadata field used for color mapping.

  • cmap_name (str, default "viridis") – Matplotlib colormap name.

  • vmin (float, default 0.0) – Minimum value for colormap normalization.

  • vmax (float, default 100.0) – Maximum value for colormap normalization.

Return type:

None

property data#
from_state(state, available_vars)#

Restore the full plot state from a previously saved dict.

Guards against missing keys so that layouts saved by older versions of pynaviz can still be loaded without error.

Parameters:
  • state (dict) – Dictionary produced by get_state().

  • available_vars (dict) – Mapping of variable name nap variable used to look up overlays by name.

get_plot_state()[source]#

Return the current display mode and its serializable state.

Returns:

{"mode": str, "mode_state": ...} where mode_state is whatever the active mode’s get_state() returns.

Return type:

dict

get_state()#

Return the full serializable state of this plot.

Aggregates three layers:

  • "manager": sort_by / group_by / color_by actions.

  • "interval_sets": overlay color and alpha keyed by label.

  • "plot": plot-type-specific state (mode, scale, clim, …).

Return type:

dict

property graphic#

The active pygfx graphic, delegated to the current display mode.

group_by(metadata_name, **kwargs)[source]#

Group channels vertically by a metadata field.

Parameters:

metadata_name (str) – Metadata key to group by.

jump_to_next_epoch()#

Jump to the start of the next superposed epoch (across all added interval sets).

Return type:

None

jump_to_previous_epoch()#

Jump to the start of the previous superposed epoch (across all added interval sets).

Return type:

None

plot_x_vs_y(x_col, y_col, color=None, thickness=1.0, markersize=10.0)[source]#

Plot one column versus another with a time-point marker.

Parameters:
  • x_col (str or int or float) – Column name for the x-axis.

  • y_col (str or int or float) – Column name for the y-axis.

  • color (str or tuple, optional) – Line color. Defaults to a color that contrasts with the background.

  • thickness (float, default 1.0) – Line thickness.

  • markersize (float, default 10.0) – Size of the time marker.

Return type:

None

remove_interval_set(label)#

Remove an interval set from the plot.

Parameters:

label (str) – The label of the interval set to be removed.

Return type:

None

set_plot_state(state, available_vars=None)[source]#

Restore display mode and mode-specific state.

Parameters:
Return type:

None

show()#

To show the canvas in case of GLFW context used

sort_by(metadata_name, mode='ascending')[source]#

Sort channels vertically by a metadata field.

Parameters:
  • metadata_name (str) – Metadata key to sort by.

  • mode (str, optional) – “ascending” (default) or “descending”.

Return type:

None

update_interval_set(name, colors, alpha)#

Update the color and transparency of an existing interval set.

Parameters:
  • name (str) – The label of the interval set to be updated.

  • colors (str | Color) – The new color of the interval set.

  • alpha (float) – The new transparency level, between 0 and 1.

Return type:

None