pyvista.DataSetAttributes.set_vectors#
- DataSetAttributes.set_vectors(vectors: ndarray[Any, dtype[number]] | Sequence[ndarray[Any, dtype[number]] | Sequence[int | float]], 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.- Parameters:
Notes
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()
.Examples
Add random vectors to a mesh as point data.
>>> import pyvista as pv >>> import numpy as np >>> mesh = pv.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