DataSetFilters.clip_scalar#
- DataSetFilters.clip_scalar(
- *,
- scalars: str | None = None,
- invert: bool = True,
- value: float | VectorLikeFloat = 0.0,
- inplace: bool = False,
- progress_bar: bool = False,
- both: bool = False,
Clip a dataset by a scalar.
Changed in version 0.49: Points that a
PolyDatainput keeps apart are no longer merged, unless it holds triangle strips.- Parameters:
- scalars
str, 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 belowvaluewill be kept. WhenFalse, only values abovevaluewill be kept.- value
float|VectorLikeFloat, default: 0.0 Set the clipping value. Can also be set as a range of values. The range produces an output similar to an isovolume filter of ParaView.
- inplacebool, default:
False Update mesh in-place. Only
PolyData,PointSetandUnstructuredGridinputs support this; any other input raisesTypeError.- progress_barbool, default:
False Display a progress bar to indicate progress.
- bothbool, default:
False If
True, also returns the complementary clipped mesh.
- scalars
- Returns:
- output
pyvista.DataSet|tuple[pyvista.DataSet,pyvista.DataSet] Clipped dataset if
both=False. Ifboth=Truethen returns a tuple of both clipped datasets. APolyDatagives aPolyDataand aPointSetgives aPointSet; every other dataset gives anUnstructuredGrid.
- output
Notes#
This filter is not available on a MultiBlock. Use
clip() or
clip_box() for a composite, or apply this
filter to each block with generic_filter().
Examples#
Download Python source code | Download Jupyter notebook
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()
Clip the part of the mesh with sample_point_scalars between 200 and 250.
>>> import pyvista as pv
>>> from pyvista import examples
>>> dataset = examples.load_hexbeam()
>>> clipped = dataset.clip_scalar(
... scalars='sample_point_scalars', value=(200, 250)
... )
>>> clipped.plot()
Used In#
Gallery Examples