pyvista.DataSetFilters.warp_by_scalar#

DataSetFilters.warp_by_scalar(scalars=None, factor=1.0, normal=None, inplace=False, progress_bar=False, **kwargs)[source]#

Warp the dataset’s points by a point data scalars array’s values.

This modifies point coordinates by moving points along point normals by the scalar amount times the scale factor.

Parameters:
scalarsstr, optional

Name of scalars to warp by. Defaults to currently active scalars.

factorfloat, default: 1.0

A scaling factor to increase the scaling effect. Alias scale_factor also accepted - if present, overrides factor.

normalsequence, optional

User specified normal. If given, data normals will be ignored and the given normal will be used to project the warp.

inplacebool, default: False

If True, the points of the given dataset will be updated.

progress_barbool, default: False

Display a progress bar to indicate progress.

**kwargsdict, optional

Accepts scale_factor instead of factor.

Returns:
pyvista.DataSet

Warped Dataset. Return type matches input.

Examples

First, plot the unwarped mesh.

>>> from pyvista import examples
>>> mesh = examples.download_st_helens()
>>> mesh.plot(cmap='gist_earth', show_scalar_bar=False)
../../../_images/pyvista-DataSetFilters-warp_by_scalar-1_00_00.png

Now, warp the mesh by the 'Elevation' scalars.

>>> warped = mesh.warp_by_scalar('Elevation')
>>> warped.plot(cmap='gist_earth', show_scalar_bar=False)
../../../_images/pyvista-DataSetFilters-warp_by_scalar-1_01_00.png

See Computing Surface Normals for more examples using this filter.