General Utilities#

core.utilities.VtkErrorCatcher([...])

Context manager to temporarily catch VTK errors.

core.utilities.axis_rotation(points, angle)

Rotate points by angle about an axis.

core.utilities.is_inside_bounds(point, bounds)

Check if a point is inside a set of bounds.

core.utilities.set_error_output_file(filename)

Set a file to write out the VTK errors.

Object Conversions or Wrapping#

array_from_vtkmatrix(matrix)

Convert a vtk matrix to an array.

cubemap([path, prefix, ext])

Construct a cubemap from 6 images from a directory.

cubemap_from_filenames(image_paths)

Construct a cubemap from 6 images.

from_meshio(mesh)

Convert a meshio mesh instance to a PyVista mesh.

from_trimesh(mesh, *[, pass_data])

Convert a Trimesh mesh to a PyVista mesh.

image_to_texture(image)

Convert pyvista.ImageData to a pyvista.Texture.

is_meshio_mesh(obj)

Test if passed object is an instance of meshio.Mesh.

is_trimesh_mesh(obj)

Test if passed object is an instance of trimesh.Trimesh.

is_pyvista_dataset(obj)

Return True if the object is a PyVista wrapped dataset.

numpy_to_texture(image)

Convert a NumPy image array to a pyvista.Texture.

pyvista_ndarray(*args, **kwargs)

A ndarray which references the owning dataset and the underlying vtk array.

to_meshio(mesh)

Convert a PyVista mesh to a meshio mesh instance.

to_trimesh(mesh, *[, triangulate, pass_data])

Convert a PyVista mesh to a Trimesh mesh.

vtkmatrix_from_array(array)

Convert a numpy.ndarray or array-like to a vtk matrix.

wrap(dataset, *[, validate])

Wrap any given VTK data object to its appropriate PyVista data object.

Features#

cartesian_to_spherical(x, y, z)

Convert 3D Cartesian coordinates to spherical coordinates.

cell_quality_info(cell_type, quality_measure)

Return information about a cell's quality measure.

create_grid(dataset[, dimensions])

Create a uniform grid surrounding the given dataset.

grid_from_sph_coords(theta, phi, r)

Create a structured grid from arrays of spherical coordinates.

merge(datasets[, merge_points, ...])

Merge several datasets.

perlin_noise(amplitude, freq, phase)

Return the implicit function that implements Perlin noise.

principal_axes(points, *[, return_std])

Compute the principal axes of a set of points.

sample_function(function[, bounds, dim, ...])

Sample an implicit function over a structured point set.

spherical_to_cartesian(r, phi, theta)

Convert Spherical coordinates to 3D Cartesian coordinates.

transform_vectors_sph_to_cart(theta, phi, r, ...)

Transform vectors from spherical (r, phi, theta) to cartesian coordinates (z, y, x).

voxelize(mesh[, density, check_surface, ...])

Voxelize mesh to UnstructuredGrid.

voxelize_volume(mesh[, density, ...])

Voxelize mesh to create a RectilinearGrid voxel volume.

File IO#

get_ext(filename)

Extract the extension of the filename.

read(filename[, force_ext, file_format, ...])

Read any file type supported by vtk or meshio.

read_exodus(filename[, animate_mode_shapes, ...])

Read an ExodusII file ('.e' or '.exo').

read_grdecl(filename[, elevation, ...])

Read a GRDECL file ('.GRDECL').

read_meshio(filename[, file_format])

Read any mesh file using meshio.

read_pickle(filename)

Load a pickled mesh from file.

read_texture(filename[, progress_bar])

Load a texture from an image file.

save_meshio(filename, mesh[, file_format])

Save mesh to file using meshio.

save_pickle(filename, mesh)

Pickle a mesh and save it to file.

set_pickle_format(format)

Set the format used to serialize pyvista.DataObject when pickled.

Mesh Creation#

fit_line_to_points(points, *[, resolution, ...])

Fit a line to points using its principal_axes().

fit_plane_to_points(points[, return_meta, ...])

Fit a plane to points using its principal_axes().

generate_plane(normal, origin)

Return a vtkPlane.

line_segments_from_points(points)

Generate non-connected line segments from points.

lines_from_points(points[, close])

Make a connected line set given an array of points.

make_tri_mesh(points, faces)

Construct a pyvista.PolyData mesh using points and faces arrays.

translate(surf[, center, direction])

Translate and orient a mesh to a new center and direction.

vector_poly_data(orig, vec)

Create a pyvista.PolyData object composed of vectors.

vtk_points(points[, deep, force_float, ...])

Convert numpy array or array-like to a vtkPoints object.

Enums#

CellType(*values)

Define types of cells.

CellStatus(*values)

Cell status bits used by cell_validator().

Array Access#

cell_array(obj, name)

Return cell array of a pyvista or vtk object.

convert_array(arr[, name, deep, array_type])

Convert a NumPy array to a vtkDataArray or vice versa.

field_array(obj, name)

Return field data of a pyvista or vtk object.

get_array(mesh, name[, preference, err])

Search point, cell and field data for an array.

get_array_association(mesh, name[, ...])

Return the array association.

point_array(obj, name)

Return point array of a pyvista or vtk object.

Transformations#

Transform(*args, **kwargs)

Describes linear transformations via a 4x4 matrix.

Image Comparison and Regression#

compare_images(im1, im2[, threshold, use_vtk])

Compare two different images of the same size.

Colors#

Color(*args, **kwargs)

Helper class to convert between different color representations used in the pyvista library.

ColorLike

Represent a union type

Named colors supported by Color, Plotter, and other plotting-related methods:

Named colormaps supported by LookupTable, Plotter, and other plotting-related methods:

Miscellaneous#

set_new_attribute(obj, name, value)

Set a new attribute for this object.

allow_new_attributes

Context manager to control setting new attributes on PyVista classes.

get_gpu_info()

Get all information about the GPU.

GPUInfo()

A class to hold GPU details.

Observer(*args, **kwargs)

A standard class for observing VTK objects.

ProgressMonitor(*args, **kwargs)

A standard class for monitoring the progress of a VTK algorithm.

register_jupyter_backend(name, handler, *[, ...])

Register a custom Jupyter backend handler.

registered_jupyter_backends()

Return every custom Jupyter backend currently registered.

JupyterBackendRegistration(name, handler, source)

Describe one registered custom Jupyter backend.

send_errors_to_logging()

Send all VTK error/warning messages to Python's logging module.

set_jupyter_backend(backend[, name])

Set the plotting backend for a jupyter notebook.

start_xvfb([wait, window_size])

Start the virtual framebuffer Xvfb.

Report([additional, ncol, text_width, sort, ...])

Generate a PyVista software environment report.

enable_smp_tools([backend, n_threads])

Enable a VTK SMP backend for filters that support shared-memory parallelism.

set_default_active_scalars(mesh)

Set a default scalars array on mesh, if not already set.

set_default_active_vectors(mesh)

Set a default vectors array on mesh, if not already set.

vtk_verbosity

Context manager to set VTK verbosity level.

vtk_snake_case

Context manager to control access to VTK's pythonic snake_case API.

Errors and Warnings#

core.errors.AmbiguousDataError([message])

Exception when data is ambiguous, e.g. multiple active scalars can be set.

core.errors.DeprecationError([message])

Used for deprecated methods and functions.

core.errors.InvalidMeshError([message])

Error for invalid mesh properties.

core.errors.InvalidMeshWarning

Warning for invalid mesh properties.

core.errors.MissingDataError([message])

Exception when data is missing, e.g. no active scalars can be set.

core.errors.NotAllTrianglesError([message])

Exception when a mesh does not contain all triangles.

core.errors.PointSetCellOperationError([message])

Requested filter or property is not supported by the PointSet class.

core.errors.PointSetDimensionReductionError([...])

Requested filter or property is not supported by the PointSet class.

core.errors.PointSetNotSupported([message])

Requested filter or property is not supported by the PointSet class.

core.errors.PyVistaAttributeError([message])

Exception when accessing an attribute that is not part of the PyVista API.

core.errors.PyVistaDeprecationWarning

Non-supressed Deprecation Warning.

core.errors.PyVistaEfficiencyWarning

Efficiency warning.

core.errors.PyVistaFutureWarning

Non-supressed Future Warning.

core.errors.PyVistaPipelineError([message])

Exception when a VTK pipeline runs into an issue.

core.errors.VTKExecutionError([message])

Exception when a VTK output message is detected.

core.errors.VTKExecutionWarning

Warning when a VTK output message is detected.

core.errors.VTKVersionError([message])

Requested feature is not supported by the installed VTK version.

PyVista Version Information#

The PyVista library provides a way of getting the version installed in your environment.

>>> # Output the version of PyVista.
>>> import pyvista as pv
>>> pv.version_info
(0, 44, 0)

VTK Version Information#

The PyVista library is heavily dependent on VTK and provides an easy way of getting the version of VTK in your environment.

>>> # Output the version of VTK.
>>> import pyvista as pv
>>> pv.vtk_version_info
VTKVersionInfo(major=9, minor=1, micro=0)
>>> # Get the major version of VTK
>>> pv.vtk_version_info.major
9