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 (nap.IntervalSet). |
|
|
|
|
|
A time series plot for nap.Tsd objects using GPU-accelerated rendering. |
|
A GPU-accelerated visualization of a multi-columns time series (nap.TsdFrame). |
- class pynaviz.base_plot.PlotIntervalSet(data: IntervalSet, 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:
- graphic#
Dictionary of rectangle meshes for each interval.
- Type:
dict[str, gfx.Mesh] or gfx.Mesh
- class pynaviz.base_plot.PlotTsGroup(data: TsGroup, index=None, parent=None)[source]#
Bases:
_BasePlot
- class pynaviz.base_plot.PlotTsd(data: Tsd, index: int | None = None, parent: Any | None = None)[source]#
Bases:
_BasePlot
A time series plot for nap.Tsd objects using GPU-accelerated rendering.
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:
- line#
The main line plot showing the time series.
- Type:
gfx.Line
- class pynaviz.base_plot.PlotTsdFrame(data: TsdFrame, index: int | None = None, parent: Any | None = None)[source]#
Bases:
_BasePlot
A GPU-accelerated visualization of a multi-columns 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).
- 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: str, cmap_name: str = 'viridis', vmin: float = 0.0, vmax: float = 100.0) → None[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.
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: str, **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_label: str | int | float, y_label: str | int | float, color: str | tuple = 'white', thickness: float = 1.0, markersize: float = 10.0) → None[source]#
Plot one metadata column versus another as a line plot.
- Parameters:
x_label (str or int or float) – Column name for the x-axis.
y_label (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.