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)

Core API

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
Core API
Plotting API

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 (0x7fa25ab2d780)
  Ambient:                     0.0
  Ambient color:               Color(name='lightblue', hex='#add8e6ff', opacity=255)
  Anisotropy:                  0.0
  Color:                       Color(name='lightblue', hex='#add8e6ff', opacity=255)
  Culling:                     "none"
  Diffuse:                     1.0
  Diffuse color:               Color(name='lightblue', hex='#add8e6ff', opacity=255)
  Edge color:                  Color(name='black', hex='#000000ff', opacity=255)
  Edge opacity:                1.0
  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
  Roughness:                   0.5
  Show edges:                  False
  Specular:                    0.0
  Specular color:              Color(name='lightblue', hex='#add8e6ff', opacity=255)
  Specular power:              100.0
  Style:                       "Surface"

Use PyVista’s Reader classes to read data files using pyvista.get_reader().

>>> import pyvista as pv
>>> from pyvista import examples
>>> reader = pv.get_reader(examples.hexbeamfile)
>>> reader

Utilize PyVista’s helper modules, conversion tools, and geometric object creation routines.

>>> import pyvista as pv
>>> mesh = pv.ParametricSuperEllipsoid(xradius=0.1)
>>> mesh
HeaderData Arrays
N Cells19602
N Points10000
N Strips0
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 Arrays1
NameFieldTypeN CompMinMax