fastplotlib.NDVectors#
- class NDVectors(ref_index, nd_subplot, data, dims, display_dims, window_funcs=None, window_order=None, spatial_func=None, slider_maps=None, name=None, graphic_kwargs=None)[source]#
NDGraphicsubclass for n-dimensional vector rendering.Uses an
NDVectorsSlicerto produce the data slices and manages aVectorsGraphic.Every dimension that is not listed in
display_dimsbecomes a slider dimension. Each slider dim must have aReferenceRangedefined in theReferenceIndexof the parentNDWidget. The widget uses this to direct a change in theReferenceIndexand update the graphics.- Parameters:
ref_index (ReferenceIndices) – The shared reference index that delivers slider updates to this graphic.
nd_subplot (NDWSubplot) – parent NDWSubplot the NDGraphic is in
data (array-like or None) –
n-dimensional vector data, must have 3 or more dims. Index
0along the positions/directions dim gives the vector positions and index1gives the vector directions.Ex: an electric field sampled over time, an array of shape
[n_timepoints, n_vectors, 2, 2]withdimsof("time", "n_vectors", "pos_dir", "xy")anddisplay_dimsof("n_vectors", "pos_dir", "xy").Pass
Noneto create theNDVectorswithout a graphic and set the data later usingdata.dims (Sequence[str]) – Name for every dimension of
data, in order. Non-spatial dims must match keys inref_index.display_dims (tuple[str, str, str]) – The 3 spatial dims in display order:
(n_vectors, positions & directions, xy(z)). The positions/directions dim must be of size 2 and the coordinate dim of size 2 or 3.window_funcs (dict[str, tuple[WindowFuncCallable | None, int | float | None]], optional) – Per-slider-dim window functions applied around the current slider position, see
NDSlicer.window_order (tuple[str, ...], optional) – Order in which the window functions are applied across dims. Only dims listed here have their window function applied, see
NDSlicer.spatial_func (Callable[[ArrayProtocol], ArrayProtocol], optional) – A function applied to the spatial slice after the window funcs, right before rendering. It is given the slice in
display_dimsorder, i.e. the array as it is rendered, and must return an array with those same dims.slider_maps (dict[str, Callable[[Any], int] | ArrayLike], optional) – Per-slider-dim mapping from reference-space values to local array indices, see
NDSlicer.name (str, optional) – Name for this
NDGraphic, used to retrieve it withnd_subplot[name].graphic_kwargs (dict, optional) – passed to the underlying
VectorsGraphic, ex:{"color": "cyan", "size": 0.5}
See also
NDVectorsSlicerThe slicer that produces the data slices for this graphic.