3D visualization & mesh analysis · Pythonic VTK · verified against PyVista 0.48 (2026)

PyVista cheat sheet

PyVista is a Pythonic, NumPy-friendly wrapper over VTK for 3-D visualization and mesh analysis. Meshes act like objects with attached data arrays; a Plotter renders them; and filters (clip, slice, threshold, contour…) transform them with one method call. It's the standard tool for scientific/engineering 3-D: STL/OBJ/VTK files, volumes, point clouds, finite-element grids — interactive in a window, in Jupyter, or headless on a server. This sheet targets PyVista 0.48.

meshes data arrays plotting filters interact & ship gotcha most common

Verified 2026-08-25 against the official docs at docs.pyvista.org (v0.48.4). Built on VTK; integrates with NumPy, Matplotlib colormaps, trimesh, and meshio. Interactive rendering needs a GPU/display — on servers run headless (off_screen + Xvfb/EGL).

Outline

Load or build a mesh, attach scalar arrays, then Plotter.add_mesh to render. Filters return new meshes (clip/slice/threshold/contour). Finish with widgets, volume rendering, and export.

Meshes

  1. 1 · Setup & load
  2. 2 · Create meshes
  3. 3 · Data arrays

Plot & filter

  1. 4 · Plotter & add_mesh
  2. 5 · Filters
  3. 6 · Scalars & colorbars

Interact & ship

  1. 7 · Views, widgets, volume
  2. 8 · Export & Jupyter
  3. 9 · Gotchas
  4. Worth memorizing

Meshes

Load a file, build geometry, and attach data to it.

1Setup & load0.48
2Create meshesprimitives & from arrays
3Data arrayspoint_data vs cell_data

Plot & filter

Render meshes and transform them with one-call filters.

4Plotter & add_meshrender a scene
5Filtersreturn NEW meshes
6Scalars & colorbarscolor mapping

Interact & ship

Multiple views, interactive widgets, volumes, and export.

7Views, widgets, volumericher scenes
8Export & Jupyterimages, HTML, notebooks
!Common gotchasread before shipping

Worth memorizing

pv.read("f.stl") / examples.download_*one reader for all formats
pv.Sphere/Cube/PolyData(points, faces)primitives & from NumPy
mesh.point_data / cell_data["x"] = arrlength == n_points / n_cells
mesh["x"] = arr; set_active_scalarsshortcut infers by length
Plotter().add_mesh(...).show()add everything, then show()
scalars=, cmap=, clim=, opacity=, style=the add_mesh essentials
clip / slice / threshold / contourfilters return NEW meshes (assign!)
glyph / streamlines / warp_by_scalarvector fields & deformation
Plotter(shape=(1,2)) + link_views()subplots; add_mesh_clip_plane widgets
add_volume(vol, opacity="sigmoid")volume rendering of ImageData
export_html / screenshotinteractive HTML / raster image
set_jupyter_backend("trame")off_screen + Xvfb on servers