PyVista
PyVista is a high-level Pythonic interface to the Visualization Toolkit (VTK), simplifying 3D plotting, mesh data structures, and filtering methods for spatial datasets. It is an active project, currently at version 0.47.3, with frequent patch releases and minor versions addressing bugs and introducing new features.
Warnings
- breaking The behavior of `Plotter.show()` regarding image depth storage changed in v0.47. It no longer automatically stores the last image depth.
- breaking Setting new attributes on PyVista classes was restricted starting from v0.46.0.
- gotcha Performance of `mesh.ray_trace` was significantly slower in versions 0.46.0 to 0.46.3 due to the removal of `obbTree` caching.
- deprecated Accessing arrays in `DataSetAttributes` (e.g., `mesh.point_data` or `mesh.cell_data`) using integer indexing (`obj[index]`) is deprecated.
Install
-
pip install pyvista
Imports
- pyvista
import pyvista as pv
- examples
from pyvista import examples
Quickstart
import pyvista as pv from pyvista import examples # Download and load an example mesh (e.g., the Stanford dragon) mesh = examples.download_dragon() # Add scalar data based on point coordinates for coloring mesh['scalars'] = mesh.points[:, 1] # Create a plotter and add the mesh plotter = pv.Plotter() plotter.add_mesh(mesh, cmap='plasma', show_edges=True) # Set the camera position and display the plot plotter.show(cpos='xy')