DataSetAttributes.set_scalars(scalars: Union[Sequence[Union[float, int, number]], float, int, number, ndarray], name='scalars', deep_copy=False)[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.


A pyvista_ndarray, numpy.ndarray, list, tuple or scalar value.


Name to assign the scalars.

deep_copybool, optional

When True makes a full copy of the array.


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.


>>> import pyvista
>>> mesh = pyvista.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