General Utilities


Sets a file to write out the VTK errors


Convert a vtk matrix to a numpy.ndarray

pyvista.is_inside_bounds(point, bounds)

Checks if a point is inside a set of bounds. This is implemented through recursion so that this is N-dimensional.

Object Conversions


This is a convenience method to safely wrap any given VTK data object to its appropriate PyVista data object. Other formats that are supported include:

  • 2D numpy.ndarray of XYZ vertices

  • 3D numpy.ndarray representing a volume. Values will be scalars.


Return True if the Object is a PyVista wrapped dataset


Converts vtkImageData (pyvista.UniformGrid) to a vtkTexture


Convert a NumPy image array to a vtk.vtkTexture

File IO, attrs=None)

This will read any VTK file! It will figure out what reader to use then wrap the VTK object for use in PyVista.


attrs (dict, optional) – A dictionary of attributes to call on the reader. Keys of dictionary are the attribute/method names and values are the arguments passed to those calls. If you do not have any attributes to call, pass None as the value.

pyvista.read_exodus(filename, animate_mode_shapes=True, apply_displacements=True, displacement_magnitude=1.0, enabled_sidesets=None)

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

pyvista.read_texture(filename, attrs=None)

Loads a vtkTexture from an image file.


Use VTK’s legacy reader to read a file

Mesh Creation


Given an array of points, make a connected line set


points (np.ndarray) –

Points representing the vertices of the connected segments. For example, two line segments would be represented as:

np.array([[0, 0, 0], [1, 0, 0], [1, 1, 0]])


lines – PolyData with lines and cells.

Return type


pyvista.vtk_points(points, deep=True)

Convert numpy points to a vtkPoints object

pyvista.vector_poly_data(orig, vec)

Creates a vtkPolyData object composed of vectors

pyvista.fit_plane_to_points(points, return_meta=False)

Fits a plane to a set of points

  • points (np.ndarray) – Size n by 3 array of points to fit a plane through

  • return_meta (bool) – If true, also returns the center and normal used to generate the plane

Array Access

pyvista.get_array(mesh, name, preference='cell', info=False, err=False)

Searches point, cell and field data for an array

  • name (str) – The name of the array to get the range.

  • preference (str, optional) – When scalars is specified, this is the perfered scalar type to search for in the dataset. Must be either 'point', 'cell', or 'field'

  • info (bool) – Return info about the scalar rather than the array itself.

  • err (bool) – Boolean to control whether to throw an error if array is not present.

pyvista.convert_array(arr, name=None, deep=0, array_type=None)

A helper to convert a NumPy array to a vtkDataArray or vice versa

  • arr (ndarray or vtkDataArry) – A numpy array or vtkDataArry to convert

  • name (str) – The name of the data array for VTK

  • deep (bool) – if input is numpy array then deep copy values


the converted array (if input is a NumPy ndaray then returns vtkDataArray or is input is vtkDataArray then returns NumPy ndarray). If pdf==True and the input is vtkDataArry, return a pandas DataFrame.

Return type

vtkDataArray, ndarray, or DataFrame

pyvista.point_scalar(mesh, name)

Returns point scalars of a vtk object

pyvista.cell_scalar(mesh, name)

Returns cell scalars of a vtk object


This looks up the VTK type for a give python data type. Corrects for string type mapping issues.



Return type

the integer type id specified in vtkType.h


Cast vtk bit array to a char array

pyvista.convert_string_array(arr, name=None)

A helper to convert a numpy array of strings to a vtkStringArray or vice versa. Note that this is terribly inefficient - inefficient support is better than no support :). If you have ideas on how to make this faster, please consider opening a pull request.