API Reference#
In this section, you can learn more about how PyVista wraps different VTK mesh types and how you can leverage powerful 3D plotting and mesh analysis tools. Highlights of the API include:
Pythonic interface to VTK’s Python bindings
Filtering/plotting tools built for interactivity (see Widgets)
Direct access to common VTK filters (see Filters)
Intuitive plotting routines with matplotlib similar syntax (see Plotting)
Learn more about PyVista’s different mesh types and direct access to common VTK filters.
>>> import pyvista as pv
>>> mesh = pv.Sphere()
>>> sliced = mesh.slice()
>>> sliced.length
1.409317132047406
Explore PyVista’s robust plotting interface for visualizing the core data structures.
>>> import pyvista as pv
>>> mesh = pv.Cube()
>>> pl = pv.Plotter()
>>> actor = pl.add_mesh(mesh, scalars=mesh.points)
>>> actor.prop
Property (0x7ff0dbe2fe80)
Ambient: 0.0
Ambient color: Color(name='light_blue', hex='#add8e6ff', opacity=255)
Anisotropy: 0.0
Anisotropy rotation: 0.0
Color: Color(name='light_blue', hex='#add8e6ff', opacity=255)
Culling: "none"
Diffuse: 1.0
Diffuse color: Color(name='light_blue', hex='#add8e6ff', opacity=255)
Edge color: Color(name='black', hex='#000000ff', opacity=255)
Edge opacity: 1.0
Index of refraction: 1.5
Interpolation: InterpolationType.FLAT
Lighting: True
Line width: 1.0
Metallic: 0.0
Opacity: 1.0
Point size: 5.0
Render lines as tubes: False
Render points as spheres: False
Representation: RepresentationType.SURFACE
Roughness: 0.5
Show edges: False
Specular: 0.0
Specular color: Color(name='light_blue', hex='#add8e6ff', opacity=255)
Specular power: 100.0
Style: "Surface"
Read data files with pyvista.read() or the Reader classes, and
write them with pyvista.DataObject.save() or the Writer classes.
>>> import pyvista as pv
>>> from pyvista import examples
>>> reader = pv.get_reader(examples.hexbeamfile)
>>> reader
VTKDataSetReader('/home/runner/_work/pyvista/pyvista/.tox/docs-build/lib/python3.14/site-packages/pyvista/examples/hexbeam.vtk')
Utilize PyVista’s helper modules, conversion tools, and geometric object creation routines.
>>> import pyvista as pv
>>> mesh = pv.ParametricSuperEllipsoid(xradius=0.1)
>>> mesh
PolyData (0x7ff0db97b880) N Cells: 19602 N Points: 10000 N Strips: 0 X Bounds: -9.997e-02, 9.997e-02 Y Bounds: -9.999e-01, 9.994e-01 Z Bounds: -1.000e+00, 1.000e+00 N Arrays: 1
Browse PyVista’s built-in and downloadable example datasets, including the interactive dataset gallery with 200+ datasets.
>>> from pyvista import examples
>>> examples.download_bunny()
PolyData (0x7ff0db97bc40) N Cells: 69451 N Points: 35947 N Strips: 0 X Bounds: -9.469e-02, 6.101e-02 Y Bounds: 3.299e-02, 1.873e-01 Z Bounds: -6.187e-02, 5.880e-02 N Arrays: 0
Command-line interface for plotting, converting, and validating one or more mesh files, and for generating environment reports, without needing to write any Python.
$ pyvista --help
Usage: pyvista COMMAND
╭─ Commands ───────────────────────────────────────────────────────────────────╮
│ plot Plot one or more mesh files in an interactive window. │
│ compare Compare two or more mesh files side-by-side. │
│ convert Convert one or more mesh files to another format. │
│ validate Validate data, points, and cells for one or more mesh files. │
│ report Generate a PyVista software environment report. │
│ --help (-h) Display this message and exit. │
│ --version Display application version. │
╰──────────────────────────────────────────────────────────────────────────────╯