Hide Cells with Ghosting¶
Specify specific cells to hide when plotting.
This is a lightweight alternative to thresholding to quickly hide cells in a mesh without creating a new mesh.
Notably, the mesh must be cast to an
for this to work (use the
import pyvista as pv from pyvista import examples import numpy as np vol = examples.load_channels() mesh = vol.cast_to_unstructured_grid()
Decide which cells are ghosted with a criteria (feel free to adjust this or manually create this array to hide specific cells).
ghosts = np.argwhere(mesh["facies"] < 1.0) # This will act on the mesh inplace to mark those cell indices as ghosts mesh.remove_cells(ghosts)
Now we can plot the mesh and those cells will be hidden
[(534.8076211353316, 534.8076211353316, 459.80762113533166), (125.0, 125.0, 50.0), (0.0, 0.0, 1.0)]
Total running time of the script: ( 0 minutes 5.962 seconds)