DataSetFilters.warp_by_scalar#
- DataSetFilters.warp_by_scalar(
- scalars: str | None = None,
- *,
- factor: float = 1.0,
- normal: VectorLikeFloat | None = None,
- inplace: bool = False,
- progress_bar: bool = False,
- **kwargs: Any,
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:
- scalars
str, optional Name of scalars to warp by. Defaults to currently active scalars.
- factor
float, default: 1.0 A scaling factor to increase the scaling effect. Alias
scale_factoralso accepted - if present, overridesfactor.- normal
VectorLikeFloat, 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.
- **kwargs
dict, optional Accepts
scale_factorinstead offactor.
- scalars
- Returns:
pyvista.DataSetWarped Dataset. Return type matches input, except that an
ImageDataorRectilinearGridgives aStructuredGrid.
Notes#
Points are only moved along their own point normals when the dataset has
them. Without point normals, or with normal given, every point is instead
moved along that single fixed direction – vtkWarpScalar’s default is
(0, 0, 1) – rather than radially or otherwise per point. This is easy to
miss on a dataset assembled directly from coordinates, such as
grid_from_sph_coords(), where the result looks like a uniform
vertical shift instead of the intended radial warp. Use warp_by_vector()
instead when the warp direction should vary per point but the dataset has no
normals to warp along, for example using each point’s own radial direction as
the vector array.
Examples#
Download Python source code | Download Jupyter notebook
First, plot the un-warped mesh.
>>> from pyvista import examples
>>> mesh = examples.download_st_helens()
>>> mesh.plot(cmap='gist_earth', show_scalar_bar=False)
Now, warp the mesh by the 'Elevation' scalars.
>>> warped = mesh.warp_by_scalar('Elevation')
>>> warped.plot(cmap='gist_earth', show_scalar_bar=False)
See Also#
warp_by_vectorWarp along a per-point direction instead of a single fixed one.
Used In#
Guides
- Overview (1 use)
API Examples
Plotter.add_north_arrow_widget(1 use)Renderer.add_north_arrow_widget(1 use)download_mount_damavand(1 use)
Gallery Examples