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]#

NDGraphic subclass for n-dimensional vector rendering.

Uses an NDVectorsSlicer to produce the data slices and manages a VectorsGraphic.

Every dimension that is not listed in display_dims becomes a slider dimension. Each slider dim must have a ReferenceRange defined in the ReferenceIndex of the parent NDWidget. The widget uses this to direct a change in the ReferenceIndex and 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 0 along the positions/directions dim gives the vector positions and index 1 gives the vector directions.

    Ex: an electric field sampled over time, an array of shape [n_timepoints, n_vectors, 2, 2] with dims of ("time", "n_vectors", "pos_dir", "xy") and display_dims of ("n_vectors", "pos_dir", "xy").

    Pass None to create the NDVectors without a graphic and set the data later using data.

  • dims (Sequence[str]) – Name for every dimension of data, in order. Non-spatial dims must match keys in ref_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_dims order, 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 with nd_subplot[name].

  • graphic_kwargs (dict, optional) – passed to the underlying VectorsGraphic, ex: {"color": "cyan", "size": 0.5}

See also

NDVectorsSlicer

The slicer that produces the data slices for this graphic.