threshold_percent#
- PolyData.threshold_percent(percent=0.5, scalars=None, invert=False, continuous=False, preference='cell', progress_bar=False)#
Threshold the dataset by a percentage of its range on the active scalars array.
- Parameters
- percent
float
ortuple
(float
),optional
The percentage (0,1) to threshold. If value is out of 0 to 1 range, then it will be divided by 100 and checked to be in that range.
- scalars
str
,optional
Name of scalars to threshold on. Defaults to currently active scalars.
- invertbool,
optional
When invert is
True
cells are kept when their values are below the percentage of the range. When invert isFalse
, cells are kept when their value is above the percentage of the range. Default isFalse
: yielding above the threshold"value"
.- continuousbool,
optional
When
True
, the continuous interval [minimum cell scalar, maximum cell scalar] will be used to intersect the threshold bound, rather than the set of discrete scalar values from the vertices.- preference
str
,optional
When
scalars
is specified, this is the preferred array type to search for in the dataset. Must be either'point'
or'cell'
.- progress_barbool,
optional
Display a progress bar to indicate progress.
- percent
- Returns
pyvista.UnstructuredGrid
Dataset containing geometry that meets the threshold requirements.
Examples
Apply a 50% threshold filter.
>>> import pyvista >>> noise = pyvista.perlin_noise(0.1, (2, 2, 2), (0, 0, 0)) >>> grid = pyvista.sample_function(noise, [0, 1.0, -0, 1.0, 0, 1.0], ... dim=(30, 30, 30)) >>> threshed = grid.threshold_percent(0.5) >>> threshed.plot(cmap='gist_earth_r', show_scalar_bar=False, show_edges=True)
Apply a 80% threshold filter.
>>> threshed = grid.threshold_percent(0.8) >>> threshed.plot(cmap='gist_earth_r', show_scalar_bar=False, show_edges=True)
See Using Common Filters for more examples using a similar filter.