clip_scalar

UnstructuredGridFilters.clip_scalar(scalars=None, invert=True, value=0.0, inplace=False, progress_bar=False, both=False)

Clip a dataset by a scalar.

Parameters
scalarsstr, optional

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

invertbool, optional

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, optional

Set the clipping value. The default value is 0.0.

inplacebool, optional

Update mesh in-place.

progress_barbool, optional

Display a progress bar to indicate progress.

bothbool, optional

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-UnstructuredGridFilters-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-UnstructuredGridFilters-clip_scalar-1_01_00.png