{
  "cells": [
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "%matplotlib inline"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "# Hide Cells with Ghosting\n\nSpecify specific cells to hide when plotting.\n\nThis is a lightweight alternative to thresholding to quickly hide cells\nin a mesh without creating a new mesh.\n\nNotably, the mesh must be cast to an\n`pyvista.UnstructuredGrid`{.interpreted-text role=\"class\"} type for this\nto work (use the `cast_to_unstructured_grid` filter).\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "import numpy as np\n\nfrom pyvista import examples\n\nvol = examples.load_channels()\nmesh = vol.cast_to_unstructured_grid()"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "Decide which cells are ghosted with a criteria (feel free to adjust this\nor manually create this array to hide specific cells).\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "ghosts = np.argwhere(mesh[\"facies\"] < 1.0)\n\n# This will act on the mesh inplace to mark those cell indices as ghosts\nmesh.remove_cells(ghosts, inplace=True)"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "Now we can plot the mesh and those cells will be hidden\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "mesh.plot(clim=[0, 4])"
      ]
    }
  ],
  "metadata": {
    "kernelspec": {
      "display_name": "Python 3",
      "language": "python",
      "name": "python3"
    },
    "language_info": {
      "codemirror_mode": {
        "name": "ipython",
        "version": 3
      },
      "file_extension": ".py",
      "mimetype": "text/x-python",
      "name": "python",
      "nbconvert_exporter": "python",
      "pygments_lexer": "ipython3",
      "version": "3.12.2"
    }
  },
  "nbformat": 4,
  "nbformat_minor": 0
}