DataSetAttributes.set_vectors(vectors: Union[Sequence[Union[float, int]], float, int, numpy.ndarray], name: str, deep_copy=False)[source]#

Set the active vectors of this data attribute.

Vectors are a quantity that has magnitude and direction, such as normal vectors or a velocity field.

The vectors data must contain three components per cell or point. Use DataSetAttributes.set_scalars() when adding non-directional data.


A pyvista_ndarray, numpy.ndarray, list, or tuple. Must match the number of cells or points of the dataset.


Name of the vectors.

deep_copybool, optional

When True makes a full copy of the array. When False, the data references the original array without copying it.


PyVista and VTK treats vectors and scalars differently when performing operations. Vector data, unlike scalar data, is rotated along with the geometry when the DataSet is passed through a transformation filter.

When adding non-directional data (such temperature values or multi-component scalars like RGBA values), you can also use DataSetAttributes.set_scalars().


Add random vectors to a mesh as point data.

>>> import pyvista
>>> import numpy as np
>>> mesh = pyvista.Cube()
>>> mesh.clear_data()
>>> vectors = np.random.random((mesh.n_points, 3))
>>> mesh.point_data.set_vectors(vectors, 'my-vectors')
>>> mesh.point_data
pyvista DataSetAttributes
Association     : POINT
Active Scalars  : None
Active Vectors  : my-vectors
Active Texture  : None
Active Normals  : None
Contains arrays :
    my-vectors              float64  (8, 3)               VECTORS