fastplotlib.NDPositionsSlicer#
- class NDPositionsSlicer(data, dims, display_dims, slider_maps=None, display_window=100, max_display_datapoints=1_000, datapoints_window_func=None, **kwargs)[source]#
NDSlicersubclass for n-dimensional positional and timeseries data.Produces
[n_graphics, p, <value dim>]slices for aLineCollection,LineStack,ScatterCollection, orScatterStack, wherepis the datapoints dim.The
pdim is simultaneously a slider dim and a spatial dim. Rather than the generalwindow_funcsmechanism, it is windowed bydisplay_window, which selects the datapoints that are rendered, and bydatapoints_window_func, which aggregates over them.- Parameters:
data (ArrayProtocol) – n-dimensional positional data, must have 3 or more dims.
dims (Sequence[str]) –
names for each dimension in
data. Dimensions not listed indisplay_dimsare treated as slider dimensions and must appear as keys in the parentNDWidget’sref_ranges.Examples:
("trial", "line", "time", "xy") ("keypoints", "time", "xyz")
dims in the array do not need to be in the order that you want to display them, the data slice is transposed into the order given by
display_dims.display_dims (tuple[str, str, str]) – The 3 spatial dims in display order:
(n_graphics, p, <value dim>), i.e. the number of lines or scatters in the collection, the number of datapointspin each of them, and the value dim which holds the xy or xyz coordinate and must be of size 2 or 3.slider_maps (dict[str, Callable[[Any], int] | ArrayLike], optional) – See
NDSlicer. The transform for thepdim is also used to mapdisplay_windowand thedatapoints_window_funcwindow size from reference units to array indices.display_window (int, float or None, default 100) – Size of the window of the
pdim to render, in the reference units of that dim, centered on its current index. UseNoneto render every datapoint, or0to render only the datapoint at the current index.max_display_datapoints (int | None, default 1_000) – Maximum number of datapoints to render per graphic. The step size of the display window slice is set from this using floor division.
Nonerenders every datapoint in the window, with no decimation. NeitherNonenor a very large value is recommended: the entire window is then read into RAM and uploaded, which is slow for a large window over a large array.datapoints_window_func (tuple[Callable, str, int | float], optional) –
Window function applied along the
pdim after the display window has been taken, as(func, apply_dims, window_size)where:func must accept an
axis: intkwarg (ex:np.mean,np.max). It is given a sliding window view of the data and is reduced along the window axis.apply_dims names the coordinates of the value dim to apply it to, one of
"all", "x", "y", "z", "xy", "xz", "yz", "xyz". Coordinates that are not named are passed through unchanged.window_size is in the reference units of the
pdim. It is mapped to array indices, clamped to a minimum of 3, and rounded up to an odd size.
Important note: if used,
display_windowis approximate and not exact due to padding from the window size. The window function is skipped whendisplay_windowis0, or when the display window spans more than2 * max_display_datapointsarray indices, which would be too expensive to compute.kwargs – passed to
NDSlicer, i.e.window_funcs,window_orderandspatial_func.
See also
NDSlicerBase class with full parameter documentation.
NDPositionsThe
NDGraphicthat uses this slicer by default.