pynaviz.base_plot#
Simple plotting class for each pynapple object. Create a unique canvas/renderer for each class
Classes
|
A visualization of a set of non-overlapping epochs ( |
|
Visualization for pynapple timestamps object ( |
|
Visualization for plotting multiple spike trains ( |
|
Visualization for 1-dimensional pynapple time series object ( |
|
Visualization of a multi-columns pynapple time series ( |
- class pynaviz.base_plot.PlotIntervalSet(data, index=None, parent=None)[source]#
Bases:
_BasePlotA 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:
- controller#
Active interactive controller for zooming or selecting.
- Type:
SpanController
- graphic#
Dictionary of rectangle meshes for each interval.
- Type:
dict[str,gfx.Mesh]orgfx.Mesh
- class pynaviz.base_plot.PlotTs(data, index=None, parent=None)[source]#
Bases:
_BasePlotVisualization for pynapple timestamps object (
nap.Ts) as vertical tick marks.- Parameters:
- class pynaviz.base_plot.PlotTsGroup(data, index=None, parent=None)[source]#
Bases:
_BasePlotVisualization 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.
- class pynaviz.base_plot.PlotTsd(data, index=None, parent=None)[source]#
Bases:
_BasePlotVisualization 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:
- 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:
_BasePlotVisualization 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], defaultNone) – Unique ID for synchronizing with external controllers.parent (
Optional[Any], defaultNone) – 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]orgfx.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, default0.0) – Minimum value for the colormap normalization.vmax (
float, default100.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.