clip_scalar#
- DataSet.clip_scalar(scalars=None, invert=True, value=0.0, inplace=False, progress_bar=False, both=False)#
Clip a dataset by a scalar.
- Parameters
- scalars
str
,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 belowvalue
will be kept. WhenFalse
, only values abovevalue
will be kept.- value
float
,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.
- scalars
- Returns
pyvista.PolyData
ortuple
Clipped dataset if
both=False
. Ifboth=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()
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()