pyvista.DataSetFilters.clip_scalar#

DataSetFilters.clip_scalar(
scalars=None,
invert=True,
value=0.0,
inplace=False,
progress_bar=False,
both=False,
)[source]#

Clip a dataset by a scalar.

Parameters:
scalarsstr, optional

Name of scalars to clip on. Defaults to currently active scalars.

invertbool, default: True

Flag on whether to flip/invert the clip. When True, only the mesh below value will be kept. When False, only values above value will be kept.

valuefloat, default: 0.0

Set the clipping value.

inplacebool, default: False

Update mesh in-place.

progress_barbool, default: False

Display a progress bar to indicate progress.

bothbool, default: False

If True, also returns the complementary clipped mesh.

Returns:
pyvista.PolyData or tuple

Clipped dataset if both=False. If both=True then returns a tuple of both clipped datasets.

Examples

Remove the part of the mesh with “sample_point_scalars” above 100.

>>> import pyvista as pv
>>> from pyvista import examples
>>> dataset = examples.load_hexbeam()
>>> clipped = dataset.clip_scalar(
...     scalars="sample_point_scalars", value=100
... )
>>> clipped.plot()
../../../_images/pyvista-DataSetFilters-clip_scalar-1_00_00.png

Get clipped meshes corresponding to the portions of the mesh above and below 100.

>>> import pyvista as pv
>>> from pyvista import examples
>>> dataset = examples.load_hexbeam()
>>> _below, _above = dataset.clip_scalar(
...     scalars="sample_point_scalars", value=100, both=True
... )

Remove the part of the mesh with “sample_point_scalars” below 100.

>>> import pyvista as pv
>>> from pyvista import examples
>>> dataset = examples.load_hexbeam()
>>> clipped = dataset.clip_scalar(
...     scalars="sample_point_scalars", value=100, invert=False
... )
>>> clipped.plot()
../../../_images/pyvista-DataSetFilters-clip_scalar-1_01_00.png