- DataSet.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.
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.
Name of scalars to threshold on. Defaults to currently active scalars.
When invert is
Truecells are kept when their values are below the percentage of the range. When invert is
False, cells are kept when their value is above the percentage of the range. Default is
False: yielding above the threshold
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.
scalarsis specified, this is the preferred array type to search for in the dataset. Must be either
Display a progress bar to indicate progress.
Dataset containing geometry that meets the threshold requirements.
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.