DataSetAttributes.set_scalars#
- DataSetAttributes.set_scalars( ) None[source]#
Set the active scalars of the dataset with an array.
In VTK and PyVista, scalars are a quantity that has no direction. This can include data with multiple components (such as RGBA values) or just one component (such as temperature data).
See
DataSetAttributes.set_vectors()when adding arrays that contain magnitude and direction.
Notes#
When adding directional data (such as velocity vectors), use
DataSetAttributes.set_vectors().
Complex arrays will be represented internally as a 2 component float64 array. This is due to limitations of VTK’s native datatypes.
Examples#
Download Python source code | Download Jupyter notebook
>>> import pyvista as pv
>>> mesh = pv.Cube()
>>> mesh.clear_data()
>>> scalars = range(mesh.n_points)
>>> mesh.point_data.set_scalars(scalars, 'my-scalars')
>>> mesh.point_data
pyvista DataSetAttributes
Association : POINT
Active Scalars : my-scalars
Active Vectors : None
Active Texture : None
Active Normals : None
Contains arrays :
my-scalars int64 (8,) SCALARS