pynaviz.base_plot.PlotTsdFrame#

class pynaviz.base_plot.PlotTsdFrame(data, index=None, parent=None, window_size=None)[source]#

Bases: _BasePlot

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

This class allows dynamic rendering of each column in a nap.TsdFrame, with interactive controls for span navigation. It supports switching between standard time series display and scatter-style x-vs-y plotting between columns.

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

  • index (Optional[int], default None) – Unique ID for synchronizing with external controllers.

  • parent (Optional[Any], default None) – Optional GUI parent (e.g. QWidget in Qt).

  • window_size (float) – The time duration (in same units as data timestamps) of the streaming window. This parameter is optional and if not provided, it will be calculated to optimize memory usage (up to 256MB). It is better to provide it if you know have memory constraints.

controller#

Active interactive controller for zooming or selecting.

Type:

Union[SpanController, GetController]

graphic#

Dictionary of per-column lines or single line for x-vs-y plotting.

Type:

dict[str, gfx.Line] or gfx.Line

time_point#

A marker showing the selected time point (used in x-vs-y plotting).

Type:

Optional[gfx.Points]

__init__(data, index=None, parent=None, window_size=None)[source]#
Parameters:

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

Applies color mapping to plot elements based on a metadata field.

group_by(metadata_name, **kwargs)

Group the plotted time series lines vertically by a metadata field.

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

Plot one column versus another as a line plot.

remove_interval_set(label)

Remove an interval set from the plot.

show()

To show the canvas in case of GLFW context used

sort_by(metadata_name[, mode])

Sort the plotted time series lines vertically by a metadata field.

update_interval_set(name, colors, alpha)

Update the color and transparency of an existing interval set.

Attributes

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]#

Applies color mapping to plot elements based on a metadata field.

This method retrieves values from the given metadata field and maps them to colors using the specified colormap and value range. The mapped colors are applied to each plot element’s material. If color mappings are still being computed in a background thread, the function retries after a short delay.

Parameters:
  • metadata_name (str) – Name of the metadata field used for color mapping.

  • cmap_name (str, default "viridis") – Name of the colormap to apply (e.g., “jet”, “plasma”, “viridis”).

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

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

Return type:

None

Notes

  • If the color_mapping_thread is still running, the method defers execution by 25 milliseconds and retries automatically.

  • If no appropriate color map is found for the metadata, a warning is issued.

  • Requires self.data to support get_info() for metadata retrieval.

  • Triggers a canvas redraw by calling self.animate() after updating colors.

Warning

UserWarning

Raised when the specified metadata field has no associated color mapping.

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

Group the plotted time series lines vertically by a metadata field.

Parameters:

metadata_name (str) – Metadata key to group by.

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

Plot one column versus another as a line plot.

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 hex or RGB, default "white") – Line color.

  • thickness (float, default 1.0) – Thickness of the connecting line.

  • 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

show()#

To show the canvas in case of GLFW context used

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

Sort the plotted time series lines 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