pynaviz.base_plot#

Simple plotting class for each pynapple object. Create a unique canvas/renderer for each class

Classes

PlotIntervalSet(data[, index, parent])

A visualization of a set of non-overlapping epochs (nap.IntervalSet).

PlotTs(data[, index, parent])

Visualization for pynapple timestamps object (nap.Ts) as vertical tick marks.

PlotTsGroup(data[, index, parent])

Visualization for plotting multiple spike trains (nap.TsGroup) as a raster plot.

PlotTsd(data[, index, parent])

Visualization for 1-dimensional pynapple time series object (nap.Tsd)

PlotTsdFrame(data[, index, parent, window_size])

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

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

Bases: _BasePlot

A visualization of a set of non-overlapping epochs (nap.IntervalSet).

This class allows dynamic rendering of each interval in a nap.IntervalSet, with interactive controls for span navigation. It supports coloring, grouping, and sorting of intervals based on metadata.

Parameters:
  • data (nap.IntervalSet) – The set of intervals to be visualized, with optional metadata.

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

controller#

Active interactive controller for zooming or selecting.

Type:

SpanController

graphic#

Dictionary of rectangle meshes for each interval.

Type:

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

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

Group the intervals vertically by a metadata field.

Parameters:

metadata_name (str) – Metadata key to group by.

jump_next()[source]#

Jump to the start of the next interval in the data.

Return type:

None

jump_previous()[source]#

Jump to the start of the previous interval in the data.

Return type:

None

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

Vertically sort the plotted intervals by a metadata field.

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

  • mode (str | None)

Return type:

None

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

Bases: _BasePlot

Visualization for pynapple timestamps object (nap.Ts) as vertical tick marks.

Parameters:
  • data (nap.Ts) – A Pynapple Ts object containing spike timestamps to visualize.

  • index (Optional[int], default None) – Controller index used for synchronized interaction (e.g., panning across multiple plots).

  • parent (Optional[Any], default None) – Optional parent widget (e.g., in a Qt context).

jump_next()[source]#

Jump to the next timestamp in the data.

Return type:

None

jump_previous()[source]#

Jump to the previous timestamp in the data.

Return type:

None

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

Bases: _BasePlot

Visualization for plotting multiple spike trains (nap.TsGroup) as a raster plot.

Each unit in the group is displayed as a row, where spike times are rendered as point markers (vertical ticks). Units can be sorted or grouped based on metadata. A SpanController is used to synchronize view ranges across plots.

Parameters:
  • data (nap.TsGroup) – A Pynapple TsGroup object containing multiple spike trains.

  • index (int, optional) – Identifier for the controller instance, useful when synchronizing multiple plots.

  • parent (QWidget, optional) – Parent widget in a Qt application, if applicable.

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

Group the raster vertically by a metadata field.

Parameters:

metadata_name (str) – Metadata key to group by.

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

Sort the raster vertically by a metadata field.

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

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

Return type:

None

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

Bases: _BasePlot

Visualization for 1-dimensional pynapple time series object (nap.Tsd)

This class renders a continuous 1D time series as a line plot and manages user interaction through a SpanController. It supports optional synchronization across multiple plots and rendering via WebGPU.

Parameters:
  • data (nap.Tsd) – The time series data to be visualized (timestamps + values).

  • index (Optional[int], default None) – Controller index used for synchronized interaction (e.g., panning across multiple plots).

  • parent (Optional[Any], default None) – Optional parent widget (e.g., in a Qt context).

controller#

Manages viewport updates, syncing, and linked plot interactions.

Type:

SpanController

line#

The main line plot showing the time series.

Type:

gfx.Line

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]

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.

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

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