Plotting

When plotting with the interactive rendering windows in VTK, several keyboard shortcuts are available:

Key

Action

Linux/Windows

Mac

q

Close the rendering window

v

Isometric camera view

w

Switch all datasets to a wireframe representation

r

Reset the camera to view all datasets

s

Switch all datasets to a surface representation

shift+click or middle-click

shift+click

Pan the rendering scene

left-click

cmd+click

Rotate the rendering scene in 3D

ctrl+click

Rotate the rendering scene in 2D (view-plane)

mouse-wheel or right-click

ctl+click

Continuously zoom the rendering scene

Convenience Functions

pyvista.plot(var_item, off_screen=None, full_screen=False, screenshot=None, interactive=True, cpos=None, window_size=None, show_bounds=False, show_axes=True, notebook=None, background=None, text='', return_img=False, eye_dome_lighting=False, use_panel=None, volume=False, parallel_projection=False, **kwargs)

Convenience plotting function for a vtk or numpy object.

Parameters
  • item (vtk or numpy object) – VTK object or numpy array to be plotted.

  • off_screen (bool) – Plots off screen when True. Helpful for saving screenshots without a window popping up.

  • full_screen (bool, optional) – Opens window in full screen. When enabled, ignores window_size. Default False.

  • screenshot (str or bool, optional) –

    Saves screenshot to file when enabled. See: help(pyvistanterface.Plotter.screenshot). Default disabled.

    When True, takes screenshot and returns numpy array of image.

  • window_size (list, optional) – Window size in pixels. Defaults to [1024, 768]

  • show_bounds (bool, optional) – Shows mesh bounds when True. Default False. Alias show_grid also accepted.

  • notebook (bool, optional) – When True, the resulting plot is placed inline a jupyter notebook. Assumes a jupyter console is active.

  • show_axes (bool, optional) – Shows a vtk axes widget. Enabled by default.

  • text (str, optional) – Adds text at the bottom of the plot.

  • volume (bool, optional) – Use the add_volume method for volume rendering.

  • **kwargs (optional keyword arguments) – See help(Plotter.add_mesh) for additional options.

Returns

  • cpos (list) – List of camera position, focal point, and view up.

  • img (numpy.ndarray) – Array containing pixel RGB and alpha. Sized: [Window height x Window width x 3] for transparent_background=False [Window height x Window width x 4] for transparent_background=True Returned only when screenshot enabled

pyvista.plot_arrows(cent, direction, **kwargs)

Plots arrows as vectors

Parameters
  • cent (np.ndarray) – Accepts a single 3d point or array of 3d points.

  • directions (np.ndarray) – Accepts a single 3d point or array of 3d vectors. Must contain the same number of items as cent.

  • **kwargs (additional arguments, optional) – See help(pyvista.Plot)

Returns

Return type

Same as Plot. See help(pyvista.Plot)

pyvista.set_plot_theme(theme)

Set the plotting parameters to a predefined theme

pyvista.create_axes_orientation_box(line_width=1, text_scale=0.366667, edge_color='black', x_color=None, y_color=None, z_color=None, xlabel='X', ylabel='Y', zlabel='Z', x_face_color='red', y_face_color='green', z_face_color='blue', color_box=False, label_color=None, labels_off=False, opacity=0.5)

Create a Box axes orientation widget with labels.

Base Plotter

The base plotter class that all PyVista plotters inherit. Please note that the pyvista.BackgroundPlotter is documented under PyVista PyQt Interface.

Attributes

background_color

Returns background color of the first render window

bounds

Returns the bounds of the active renderer

camera

The active camera of the active renderer

camera_position

Returns camera position of the active render window

camera_set

Returns if the camera of the active renderer has been set

center

Returns the center of the active renderer

image

Returns an image array of current render window

image_depth

Helper attribute for get_image_depth

length

Returns the length of the diagonal of the bounding box of the scene

renderer

simply returns the active renderer

scale

The scaling of the active renderer.

window_size

returns render window size

Methods

add_actor(uinput[, reset_camera, name, loc, …])

Adds an actor to render window.

add_arrows(cent, direction[, mag])

Adds arrows to plotting object

add_axes([interactive, line_width, color, …])

Add an interactive axes widget

add_axes_at_origin([x_color, y_color, …])

Add axes actor at the origin of a render window.

add_bounding_box([color, corner_factor, …])

Adds an unlabeled and unticked box at the boundaries of plot.

add_bounds_axes(*args, **kwargs)

Deprecated

add_key_event(key, callback)

Add a function to callback when the given key is pressed.

add_legend([labels, bcolor, border, size, name])

Adds a legend to render window.

add_lines(lines[, color, width, label, name])

Adds lines to the plotting object.

add_mesh(mesh[, color, style, scalars, …])

Adds any PyVista/VTK mesh or dataset that PyVista can wrap to the scene.

add_point_labels(points, labels[, italic, …])

Creates a point actor with one label from list labels assigned to each point.

add_point_scalar_labels(points, labels[, …])

Wrapper for pyvista.BasePlotter.add_point_labels() that will label points from a dataset with their scalar values.

add_points(points, **kwargs)

Add points to a mesh

add_scalar_bar([title, n_labels, italic, …])

Creates scalar bar using the ranges as set by the last input mesh.

add_text(text[, position, font_size, color, …])

Adds text to plot object in the top left corner by default

add_volume(volume[, scalars, clim, …])

Adds a volume, rendered using a fixed point ray cast mapper by default.

clear()

Clears plot by removing all actors and properties

clear_events_for_key(key)

close()

closes render window

deep_clean()

disable()

Disable this renderer’s camera from being interactive

disable_eye_dome_lighting()

Disable eye dome lighting (EDL) for active renderer

disable_parallel_projection()

Reset the camera to use perspective projection.

enable()

Enable this renderer’s camera to be interactive

enable_eye_dome_lighting()

Enable eye dome lighting (EDL) for active renderer

enable_image_style()

sets the interactive style to image

enable_joystick_style()

sets the interactive style to joystick

enable_parallel_projection()

Set use parallel projection.

enable_rubber_band_style()

sets the interactive style to rubber band picking

enable_terrain_style()

sets the interactive style to terrain

enable_trackball_style()

sets the interactive style to trackball - the default syle

enable_zoom_style()

sets the interactive style to rubber band zoom

export_obj(filename)

Export scene to OBJ format

export_vtkjs(filename[, compress_arrays])

Export the current rendering scene as a VTKjs scene for rendering in a web browser

fly_to(point)

Given a position point, move the current camera’s focal point to that point.

generate_orbital_path([factor, n_points, …])

Genrates an orbital path around the data scene

get_default_cam_pos([negative])

Return the default camera position of the active renderer

get_image_depth([fill_value, …])

Returns a depth image representing current render window

hide_axes()

Hide the axes orientation widget

index_to_loc(index)

Convert a 1D index location to the 2D location on the plotting grid

isometric_view()

DEPRECATED: Please use view_isometric

isometric_view_interactive()

sets the current interactive render window to isometric view

key_press_event(obj, event)

Listens for key press event

left_button_down(obj, event_type)

Register the event for a left button down click

link_views([views])

Links the views’ cameras.

loc_to_index(loc)

Return index of the render window given a location index.

open_gif(filename)

Open a gif file.

open_movie(filename[, framerate])

Establishes a connection to the ffmpeg writer

orbit_on_path([path, focus, step, viewup, …])

Orbit on the given path focusing on the focus point

remove_actor(actor[, reset_camera])

Removes an actor from the Plotter.

remove_bounding_box([loc])

Removes bounding box from the active renderer.

remove_bounds_axes([loc])

Removes bounds axes from the active renderer.

remove_legend()

Removes legend actor

remove_scalar_bar()

Removes scalar bar

reset_camera()

Reset camera so it slides along the vector defined from camera position to focal point until all of the actors can be seen.

reset_key_events()

Reset all of the key press events to their defaults.

screenshot([filename, …])

Takes screenshot at current camera position

set_background(color[, loc])

Sets background color

set_focus(point)

sets focus to a point

set_position(point[, reset])

sets camera position to a point

set_scale([xscale, yscale, zscale, reset_camera])

Scale all the datasets in the scene of the active renderer.

set_viewup(vector)

sets camera viewup vector

show_axes()

Show the axes orientation widget

show_bounds([mesh, bounds, show_xaxis, …])

Adds bounds axes.

show_grid(**kwargs)

A wrapped implementation of show_bounds to change default behaviour to use gridlines and showing the axes labels on the outer edges.

subplot(index_row[, index_column])

Sets the active subplot.

unlink_views([views])

Unlinks the views’ cameras.

update([stime, force_redraw])

Update window, redraw, process messages query

update_bounds_axes()

Update the bounds of the active renderer

update_coordinates(points[, mesh, render])

Updates the points of the an object in the plotter.

update_scalar_bar_range(clim[, name])

Update the value range of the active or named scalar bar.

update_scalars(scalars[, mesh, render])

Updates scalars of the an object in the plotter.

update_style()

view_isometric([negative])

Resets the camera to a default isometric view showing all the actors in the scene.

view_vector(vector[, viewup])

view_xy([negative])

View the XY plane

view_xz([negative])

View the XZ plane

view_yx([negative])

View the YX plane

view_yz([negative])

View the YZ plane

view_zx([negative])

View the ZX plane

view_zy([negative])

View the ZY plane

write_frame()

Writes a single frame to the movie file

class pyvista.BasePlotter(shape=(1, 1), border=None, border_color='k', border_width=2.0, title=None, splitting_position=None)

Bases: pyvista.plotting.picking.PickingHelper, pyvista.plotting.widgets.WidgetHelper

To be used by the Plotter and QtInteractor classes.

Parameters
  • shape (list or tuple, optional) –

    Number of sub-render windows inside of the main window. Specify two across with shape=(2, 1) and a two by two grid with shape=(2, 2). By default there is only one renderer. Can also accept a shape as string descriptor. E.g.:

    shape=”3|1” means 3 plots on the left and 1 on the right, shape=”4/2” means 4 plots on top of 2 at bottom.

  • border (bool, optional) – Draw a border around each render window. Default False.

  • border_color (string or 3 item list, optional, defaults to white) –

    Either a string, rgb list, or hex color string. For example:

    color=’white’ color=’w’ color=[1, 1, 1] color=’#FFFFFF’

  • border_width (float, optional) – Width of the border in pixels when enabled.

add_actor(uinput, reset_camera=False, name=None, loc=None, culling=False, pickable=True)

Adds an actor to render window. Creates an actor if input is a mapper.

Parameters
  • uinput (vtk.vtkMapper or vtk.vtkActor) – vtk mapper or vtk actor to be added.

  • reset_camera (bool, optional) – Resets the camera when true.

  • loc (int, tuple, or list) – Index of the renderer to add the actor to. For example, loc=2 or loc=(1, 1). If None, selects the last active Renderer.

  • culling (bool optional) – Does not render faces that should not be visible to the plotter. This can be helpful for dense surface meshes, especially when edges are visible, but can cause flat meshes to be partially displayed. Default False.

Returns

  • actor (vtk.vtkActor) – The actor.

  • actor_properties (vtk.Properties) – Actor properties.

add_arrows(cent, direction, mag=1, **kwargs)

Adds arrows to plotting object

add_axes(interactive=None, line_width=2, color=None, x_color=None, y_color=None, z_color=None, xlabel='X', ylabel='Y', zlabel='Z', labels_off=False, box=None, box_args=None)

Add an interactive axes widget

add_axes_at_origin(x_color=None, y_color=None, z_color=None, xlabel='X', ylabel='Y', zlabel='Z', line_width=2, labels_off=False, loc=None)

Add axes actor at the origin of a render window.

Parameters

loc (int, tuple, or list) – Index of the renderer to add the actor to. For example, loc=2 or loc=(1, 1). When None, defaults to the active render window.

Returns

marker_actor – vtkAxesActor actor

Return type

vtk.vtkAxesActor

add_bounding_box(color=None, corner_factor=0.5, line_width=None, opacity=1.0, render_lines_as_tubes=False, lighting=None, reset_camera=None, loc=None)

Adds an unlabeled and unticked box at the boundaries of plot. Useful for when wanting to plot outer grids while still retaining all edges of the boundary.

Parameters
  • corner_factor (float, optional) – If all_edges, this is the factor along each axis to draw the default box. Dafuault is 0.5 to show the full box.

  • corner_factor – This is the factor along each axis to draw the default box. Dafuault is 0.5 to show the full box.

  • line_width (float, optional) – Thickness of lines.

  • opacity (float, optional) – Opacity of mesh. Should be between 0 and 1. Default 1.0

  • loc (int, tuple, or list) – Index of the renderer to add the actor to. For example, loc=2 or loc=(1, 1). If None, selects the last active Renderer.

add_bounds_axes(*args, **kwargs)

Deprecated

add_box_widget(callback, bounds=None, factor=1.25, rotation_enabled=True, color=None, use_planes=False, outline_translation=True, **kwargs)

Add a box widget to the scene. This is useless without a callback function. You can pass a callable function that takes a single argument, the PolyData box output from this widget, and performs a task with that box.

Parameters
  • callback (callable) – The method called everytime the box is updated. This has two options: Take a single argument, the PolyData box (defualt) or if use_planes=True, then it takes a single argument of the plane collection as a vtkPlanes object.

  • bounds (tuple(float)) – Length 6 tuple of the bounding box where the widget is placed.

  • factor (float, optional) – An inflation factor to expand on the bounds when placing

  • rotation_enabled (bool) – If False, the box widget cannot be rotated and is strictly orthogonal to the cartesian axes.

  • color (string or 3 item list, optional, defaults to white) – Either a string, rgb list, or hex color string.

  • use_planes (bool, optional) – Changes the arguments passed to the callback to the planes that make up the box.

  • outline_translation (bool) – If False, the box widget cannot be translated and is strictly placed at the given bounds.

add_key_event(key, callback)

Add a function to callback when the given key is pressed. These are non-unique - thus a key could map to many callback functions.

The callback function must not have any arguments.

Parameters
  • key (str) – The key to trigger the event

  • callback (callable) – A callable that takes no arguments

add_legend(labels=None, bcolor=(0.5, 0.5, 0.5), border=False, size=None, name=None)

Adds a legend to render window. Entries must be a list containing one string and color entry for each item.

Parameters
  • labels (list, optional) –

    When set to None, uses existing labels as specified by

    • add_mesh

    • add_lines

    • add_points

    List contianing one entry for each item to be added to the legend. Each entry must contain two strings, [label, color], where label is the name of the item to add, and color is the color of the label to add.

  • bcolor (list or string, optional) – Background color, either a three item 0 to 1 RGB color list, or a matplotlib color string (e.g. ‘w’ or ‘white’ for a white color). If None, legend background is disabled.

  • border (bool, optional) – Controls if there will be a border around the legend. Default False.

  • size (list, optional) – Two float list, each float between 0 and 1. For example [0.1, 0.1] would make the legend 10% the size of the entire figure window.

  • name (str, optional) – The name for the added actor so that it can be easily updated. If an actor of this name already exists in the rendering window, it will be replaced by the new actor.

Returns

legend – Actor for the legend.

Return type

vtk.vtkLegendBoxActor

Examples

>>> import pyvista
>>> from pyvista import examples
>>> mesh = examples.load_hexbeam()
>>> othermesh = examples.load_uniform()
>>> plotter = pyvista.Plotter()
>>> _ = plotter.add_mesh(mesh, label='My Mesh')
>>> _ = plotter.add_mesh(othermesh, 'k', label='My Other Mesh')
>>> _ = plotter.add_legend()
>>> plotter.show() 

Alternative manual example

>>> import pyvista
>>> from pyvista import examples
>>> mesh = examples.load_hexbeam()
>>> othermesh = examples.load_uniform()
>>> legend_entries = []
>>> legend_entries.append(['My Mesh', 'w'])
>>> legend_entries.append(['My Other Mesh', 'k'])
>>> plotter = pyvista.Plotter()
>>> _ = plotter.add_mesh(mesh)
>>> _ = plotter.add_mesh(othermesh, 'k')
>>> _ = plotter.add_legend(legend_entries)
>>> plotter.show() 
add_line_widget(callback, bounds=None, factor=1.25, resolution=100, color=None, use_vertices=False, **kwargs)

Add a line widget to the scene. This is useless without a callback function. You can pass a callable function that takes a single argument, the PolyData line output from this widget, and performs a task with that line.

Parameters
  • callback (callable) – The method called everytime the line is updated. This has two options: Take a single argument, the PolyData line (defualt) or if use_vertices=True, then it can take two arguments of the coordinates of the line’s end points.

  • bounds (tuple(float)) – Length 6 tuple of the bounding box where the widget is placed.

  • factor (float, optional) – An inflation factor to expand on the bounds when placing

  • resolution (int) – The number of points in the line created

  • color (string or 3 item list, optional, defaults to white) – Either a string, rgb list, or hex color string.

  • use_vertices (bool, optional) – Changess the arguments of the callback method to take the end points of the line instead of a PolyData object.

add_lines(lines, color=(1, 1, 1), width=5, label=None, name=None)

Adds lines to the plotting object.

Parameters
  • lines (np.ndarray or pyvista.PolyData) –

    Points representing line segments. For example, two line segments would be represented as:

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

  • color (string or 3 item list, optional, defaults to white) –

    Either a string, rgb list, or hex color string. For example:

    color=’white’ color=’w’ color=[1, 1, 1] color=’#FFFFFF’

  • width (float, optional) – Thickness of lines

  • name (str, optional) – The name for the added actor so that it can be easily updated. If an actor of this name already exists in the rendering window, it will be replaced by the new actor.

Returns

actor – Lines actor.

Return type

vtk.vtkActor

add_mesh(mesh, color=None, style=None, scalars=None, clim=None, show_edges=None, edge_color=None, point_size=5.0, line_width=None, opacity=1.0, flip_scalars=False, lighting=None, n_colors=256, interpolate_before_map=True, cmap=None, label=None, reset_camera=None, scalar_bar_args=None, show_scalar_bar=None, stitle=None, multi_colors=False, name=None, texture=None, render_points_as_spheres=None, render_lines_as_tubes=False, smooth_shading=False, ambient=0.0, diffuse=1.0, specular=0.0, specular_power=100.0, nan_color=None, nan_opacity=1.0, loc=None, backface_culling=False, rgb=False, categories=False, use_transparency=False, below_color=None, above_color=None, annotations=None, pickable=True, **kwargs)

Adds any PyVista/VTK mesh or dataset that PyVista can wrap to the scene. This method using a mesh representation to view the surfaces and/or geometry of datasets. For volume rendering, see pyvista.BasePlotter.add_volume().

Parameters
  • mesh (pyvista.Common or pyvista.MultiBlock) – Any PyVista or VTK mesh is supported. Also, any dataset that pyvista.wrap() can handle including NumPy arrays of XYZ points.

  • color (string or 3 item list, optional, defaults to white) – Use to make the entire mesh have a single solid color. Either a string, RGB list, or hex color string. For example: color='white', color='w', color=[1, 1, 1], or color='#FFFFFF'. Color will be overridden if scalars are specified.

  • style (string, optional) – Visualization style of the mesh. One of the following: style='surface', style='wireframe', style='points'. Defaults to 'surface'. Note that 'wireframe' only shows a wireframe of the outer geometry.

  • scalars (str or numpy.ndarray, optional) – Scalars used to “color” the mesh. Accepts a string name of an array that is present on the mesh or an array equal to the number of cells or the number of points in the mesh. Array should be sized as a single vector. If both color and scalars are None, then the active scalars are used.

  • clim (2 item list, optional) – Color bar range for scalars. Defaults to minimum and maximum of scalars array. Example: [-1, 2]. rng is also an accepted alias for this.

  • show_edges (bool, optional) – Shows the edges of a mesh. Does not apply to a wireframe representation.

  • edge_color (string or 3 item list, optional, defaults to black) – The solid color to give the edges when show_edges=True. Either a string, RGB list, or hex color string.

  • point_size (float, optional) – Point size of any nodes in the dataset plotted. Also applicable when style=’points’. Default 5.0

  • line_width (float, optional) – Thickness of lines. Only valid for wireframe and surface representations. Default None.

  • opacity (float, str, array-like) – Opacity of the mesh. If a siblge float value is given, it will be the global opacity of the mesh and uniformly applied everywhere - should be between 0 and 1. A string can also be specified to map the scalar range to a predefined opacity transfer function (options include: ‘linear’, ‘linear_r’, ‘geom’, ‘geom_r’). A string could also be used to map a scalar array from the mesh to the the opacity (must have same number of elements as the scalars argument). Or you can pass a custum made trasfer function that is an aray either n_colors in length or shorter.

  • flip_scalars (bool, optional) – Flip direction of cmap. Most colormaps allow *_r suffix to do this as well.

  • lighting (bool, optional) – Enable or disable view direction lighting. Default False.

  • n_colors (int, optional) – Number of colors to use when displaying scalars. Defaults to 256. The scalar bar will also have this many colors.

  • interpolate_before_map (bool, optional) – Enabling makes for a smoother scalar display. Default is True. When False, OpenGL will interpolate the mapped colors which can result is showing colors that are not present in the color map.

  • cmap (str, optional) – Name of the Matplotlib colormap to us when mapping the scalars. See available Matplotlib colormaps. Only applicable for when displaying scalars. Requires Matplotlib to be installed. colormap is also an accepted alias for this. If colorcet or cmocean are installed, their colormaps can be specified by name.

  • label (str, optional) – String label to use when adding a legend to the scene with pyvista.BasePlotter.add_legend()

  • reset_camera (bool, optional) – Reset the camera after adding this mesh to the scene

  • scalar_bar_args (dict, optional) – Dictionary of keyword arguments to pass when adding the scalar bar to the scene. For options, see pyvista.BasePlotter.add_scalar_bar().

  • show_scalar_bar (bool) – If False, a scalar bar will not be added to the scene. Defaults to True.

  • stitle (string, optional) – Scalar bar title. By default the scalar bar is given a title of the the scalar array used to color the mesh. To create a bar with no title, use an empty string (i.e. ‘’).

  • multi_colors (bool, optional) – If a MultiBlock dataset is given this will color each block by a solid color using matplotlib’s color cycler.

  • name (str, optional) – The name for the added mesh/actor so that it can be easily updated. If an actor of this name already exists in the rendering window, it will be replaced by the new actor.

  • texture (vtk.vtkTexture or np.ndarray or boolean, optional) – A texture to apply if the input mesh has texture coordinates. This will not work with MultiBlock datasets. If set to True, the first avaialble texture on the object will be used. If a string name is given, it will pull a texture with that name associated to the input mesh.

  • render_points_as_spheres (bool, optional) –

  • render_lines_as_tubes (bool, optional) –

  • smooth_shading (bool, optional) –

  • ambient (float, optional) – When lighting is enabled, this is the amount of light from 0 to 1 that reaches the actor when not directed at the light source emitted from the viewer. Default 0.0

  • diffuse (float, optional) – The diffuse lighting coefficient. Default 1.0

  • specular (float, optional) – The specular lighting coefficient. Default 0.0

  • specular_power (float, optional) – The specular power. Bewteen 0.0 and 128.0

  • nan_color (string or 3 item list, optional, defaults to gray) – The color to use for all NaN values in the plotted scalar array.

  • nan_opacity (float, optional) – Opacity of NaN values. Should be between 0 and 1. Default 1.0

  • loc (int, tuple, or list) – Index of the renderer to add the actor to. For example, loc=2 or loc=(1, 1). If None, selects the last active Renderer.

  • backface_culling (bool optional) – Does not render faces that should not be visible to the plotter. This can be helpful for dense surface meshes, especially when edges are visible, but can cause flat meshes to be partially displayed. Defaults False.

  • rgb (bool, optional) – If an 2 dimensional array is passed as the scalars, plot those values as RGB(A) colors! rgba is also accepted alias for this. Opacity (the A) is optional.

  • categories (bool, optional) – If set to True, then the number of unique values in the scalar array will be used as the n_colors argument.

  • use_transparency (bool, optional) – Invert the opacity mappings and make the values correspond to transperency.

  • below_color (string or 3 item list, optional) – Solid color for values below the scalar range (clim). This will automatically set the scalar bar below_label to 'Below'

  • above_color (string or 3 item list, optional) – Solid color for values below the scalar range (clim). This will automatically set the scalar bar above_label to 'Above'

  • annotations (dict, optional) – Pass a dictionary of annotations. Keys are the float values in the scalar range to annotate on the scalar bar and the values are the the string annotations.

  • pickable (bool) – Set whether this mesh is pickable

Returns

actor – VTK actor of the mesh.

Return type

vtk.vtkActor

add_mesh_clip_box(mesh, invert=False, rotation_enabled=True, widget_color=None, outline_translation=True, **kwargs)

Add a mesh to the scene with a box widget that is used to clip the mesh interactively.

The clipped mesh is saved to the .box_clipped_meshes attribute on the plotter.

Parameters
  • mesh (pyvista.Common) – The input dataset to add to the scene and clip

  • invert (bool) – Flag on whether to flip/invert the clip

  • rotation_enabled (bool) – If False, the box widget cannot be rotated and is strictly orthogonal to the cartesian axes.

  • kwargs (dict) – All additional keyword arguments are passed to add_mesh to control how the mesh is displayed.

add_mesh_clip_plane(mesh, normal='x', invert=False, widget_color=None, value=0.0, assign_to_axis=None, tubing=False, origin_translation=True, outline_translation=False, **kwargs)

Add a mesh to the scene with a plane widget that is used to clip the mesh interactively.

The clipped mesh is saved to the .plane_clipped_meshes attribute on the plotter.

Parameters
  • mesh (pyvista.Common) – The input dataset to add to the scene and clip

  • noraml (str or tuple(flaot)) – The starting normal vector of the plane

  • invert (bool) – Flag on whether to flip/invert the clip

  • kwargs (dict) – All additional keyword arguments are passed to add_mesh to control how the mesh is displayed.

add_mesh_isovalue(mesh, scalars=None, compute_normals=False, compute_gradients=False, compute_scalars=True, preference='point', title=None, pointa=(0.4, 0.9), pointb=(0.9, 0.9), widget_color=None, **kwargs)

Add a mesh to the scene with a slider widget that is used to contour at an isovalue of the point data on the mesh interactively.

The isovalue mesh is saved to the .isovalue_meshes attribute on the plotter.

Parameters
  • mesh (pyvista.Common) – The input dataset to add to the scene and contour

  • scalars (str) – The string name of the scalars on the mesh to threshold and display

  • kwargs (dict) – All additional keyword arguments are passed to add_mesh to control how the mesh is displayed.

add_mesh_slice(mesh, normal='x', generate_triangles=False, widget_color=None, assign_to_axis=None, tubing=False, origin_translation=True, outline_translation=False, **kwargs)

Add a mesh to the scene with a plane widget that is used to slice the mesh interactively.

The sliced mesh is saved to the .plane_sliced_meshes attribute on the plotter.

Parameters
  • mesh (pyvista.Common) – The input dataset to add to the scene and slice

  • noraml (str or tuple(flaot)) – The starting normal vector of the plane

  • generate_triangles (bool, optional) – If this is enabled (False by default), the output will be triangles otherwise, the output will be the intersection polygons.

  • kwargs (dict) – All additional keyword arguments are passed to add_mesh to control how the mesh is displayed.

add_mesh_slice_orthogonal(mesh, generate_triangles=False, widget_color=None, tubing=False, **kwargs)

Adds three interactive plane slicing widgets for orthogonal slicing along each cartesian axis.

add_mesh_slice_spline(mesh, generate_triangles=False, n_hanldes=5, resolution=25, widget_color=None, show_ribbon=False, ribbon_color='pink', ribbon_opacity=0.5, **kwargs)

Add a mesh to the scene with a spline widget that is used to slice the mesh interactively.

The sliced mesh is saved to the .spline_sliced_meshes attribute on the plotter.

Parameters
  • mesh (pyvista.Common) – The input dataset to add to the scene and slice along the spline

  • generate_triangles (bool, optional) – If this is enabled (False by default), the output will be triangles otherwise, the output will be the intersection polygons.

  • kwargs (dict) – All additional keyword arguments are passed to add_mesh to control how the mesh is displayed.

add_mesh_threshold(mesh, scalars=None, invert=False, widget_color=None, preference='cell', title=None, pointa=(0.4, 0.9), pointb=(0.9, 0.9), continuous=False, **kwargs)

Add a mesh to the scene with a slider widget that is used to threshold the mesh interactively.

The threshold mesh is saved to the .threshold_meshes attribute on the plotter.

Parameters
  • mesh (pyvista.Common) – The input dataset to add to the scene and threshold

  • scalars (str) – The string name of the scalars on the mesh to threshold and display

  • invert (bool) – Invert/flip the threshold

  • kwargs (dict) – All additional keyword arguments are passed to add_mesh to control how the mesh is displayed.

add_plane_widget(callback, normal='x', origin=None, bounds=None, factor=1.25, color=None, assign_to_axis=None, tubing=False, outline_translation=False, origin_translation=True, **kwargs)

Add a plane widget to the scene. This is useless without a callback function. You can pass a callable function that takes two arguments, the normal and origin of the plane in that order output from this widget, and performs a task with that plane.

Parameters
  • callback (callable) – The method called everytime the plane is updated. Takes two arguments, the normal and origin of the plane in that order.

  • noraml (str or tuple(flaot)) – The starting normal vector of the plane

  • origin (tuple(float)) – The starting coordinate of the center of the place

  • bounds (tuple(float)) – Length 6 tuple of the bounding box where the widget is placed.

  • factor (float, optional) – An inflation factor to expand on the bounds when placing

  • color (string or 3 item list, optional, defaults to white) – Either a string, rgb list, or hex color string.

  • translation_enabled (bool) – If False, the box widget cannot be translated and is strictly placed at the given bounds.

add_point_labels(points, labels, italic=False, bold=True, font_size=None, text_color=None, font_family=None, shadow=False, show_points=True, point_color=None, point_size=5, name=None, shape_color='grey', shape='rounded_rect', fill_shape=True, margin=3, shape_opacity=1.0, pickable=True, render_points_as_spheres=False, **kwargs)

Creates a point actor with one label from list labels assigned to each point.

Parameters
  • points (np.ndarray or pyvista.Common) – n x 3 numpy array of points or pyvista dataset with points

  • labels (list or str) – List of labels. Must be the same length as points. If a string name is given with a pyvista.Common input for points, then these are fetched.

  • italic (bool, optional) – Italicises title and bar labels. Default False.

  • bold (bool, optional) – Bolds title and bar labels. Default True

  • font_size (float, optional) – Sets the size of the title font. Defaults to 16.

  • text_color (string or 3 item list, optional) –

    Color of text. Either a string, rgb list, or hex color string.

    text_color=’white’ text_color=’w’ text_color=[1, 1, 1] text_color=’#FFFFFF’

  • font_family (string, optional) – Font family. Must be either courier, times, or arial.

  • shadow (bool, optional) – Adds a black shadow to the text. Defaults to False

  • show_points (bool, optional) – Controls if points are visible. Default True

  • point_color (string or 3 item list, optional. Color of points (if visible)) –

    Either a string, rgb list, or hex color string. For example:

    text_color=’white’ text_color=’w’ text_color=[1, 1, 1] text_color=’#FFFFFF’

  • point_size (float, optional) – Size of points (if visible)

  • name (str, optional) – The name for the added actor so that it can be easily updated. If an actor of this name already exists in the rendering window, it will be replaced by the new actor.

shape_colorstring or 3 item list, optional. Color of points (if visible).

Either a string, rgb list, or hex color string. For example:

shapestr, optional

The string name of the shape to use. Options are 'rect' or 'rounded_rect'. If you want no shape, pass None

fill_shapebool, optional

Fill the shape with the shape_color. Outlines if False.

marginint, optional

The size of the margin on the label background shape. Default is 3.

shape_opacityflaot

The opacity of the shape between zero and one.

Returns

labelMapper – VTK label mapper. Can be used to change properties of the labels.

Return type

vtk.vtkvtkLabeledDataMapper

add_point_scalar_labels(points, labels, fmt=None, preamble='', **kwargs)

Wrapper for pyvista.BasePlotter.add_point_labels() that will label points from a dataset with their scalar values.

Parameters
  • points (np.ndarray or pyvista.Common) – n x 3 numpy array of points or pyvista dataset with points

  • labels (str) – String name of the point data array to use.

  • fmt (str) – String formatter used to format numerical data

add_points(points, **kwargs)

Add points to a mesh

add_scalar_bar(title=None, n_labels=5, italic=False, bold=True, title_font_size=None, label_font_size=None, color=None, font_family=None, shadow=False, mapper=None, width=None, height=None, position_x=None, position_y=None, vertical=None, interactive=False, fmt=None, use_opacity=True, outline=False, nan_annotation=False, below_label=None, above_label=None, background_color=None, n_colors=None)

Creates scalar bar using the ranges as set by the last input mesh.

Parameters
  • title (string, optional) – Title of the scalar bar. Default None

  • n_labels (int, optional) – Number of labels to use for the scalar bar.

  • italic (bool, optional) – Italicises title and bar labels. Default False.

  • bold (bool, optional) – Bolds title and bar labels. Default True

  • title_font_size (float, optional) – Sets the size of the title font. Defaults to None and is sized automatically.

  • label_font_size (float, optional) – Sets the size of the title font. Defaults to None and is sized automatically.

  • color (string or 3 item list, optional, defaults to white) –

    Either a string, rgb list, or hex color string. For example:

    color=’white’ color=’w’ color=[1, 1, 1] color=’#FFFFFF’

  • font_family (string, optional) – Font family. Must be either courier, times, or arial.

  • shadow (bool, optional) – Adds a black shadow to the text. Defaults to False

  • width (float, optional) – The percentage (0 to 1) width of the window for the colorbar

  • height (float, optional) – The percentage (0 to 1) height of the window for the colorbar

  • position_x (float, optional) – The percentage (0 to 1) along the windows’s horizontal direction to place the bottom left corner of the colorbar

  • position_y (float, optional) – The percentage (0 to 1) along the windows’s vertical direction to place the bottom left corner of the colorbar

  • interactive (bool, optional) – Use a widget to control the size and location of the scalar bar.

  • use_opacity (bool, optional) – Optionally disply the opacity mapping on the scalar bar

  • outline (bool, optional) – Optionally outline the scalar bar to make opacity mappings more obvious.

  • nan_annotation (bool, optional) – Annotate the NaN color

  • below_label (str, optional) – String annotation for values below the scalar range

  • above_label (str, optional) – String annotation for values above the scalar range

  • background_color (array, optional) – The color used for the background in RGB format.

  • n_colors (int, optional) – The maximum number of color displayed in the scalar bar.

Notes

Setting title_font_size, or label_font_size disables automatic font sizing for both the title and label.

add_slider_widget(callback, rng, value=None, title=None, pointa=(0.4, 0.9), pointb=(0.9, 0.9), color=None)

Add a slider bar widget. This is useless without a callback function. You can pass a callable function that takes a single argument, the value of this slider widget, and performs a task with that value.

Parameters
  • callback (callable) – The method called everytime the slider is updated. This should take a single parameter: the float value of the slider

  • rng (tuple(float)) – Length two tuple of the minimum and maximum ranges of the slider

  • value (float, optional) – The starting value of the slider

  • title (str) – The string label of the slider widget

  • pointa (tuple(float)) – The relative coordinates of the left point of the slider on the display port

  • pointb (tuple(float)) – The relative coordinates of the right point of the slider on the display port

  • color (string or 3 item list, optional, defaults to white) – Either a string, rgb list, or hex color string.

add_sphere_widget(callback, center=(0, 0, 0), radius=0.5, theta_resolution=30, phi_resolution=30, color=None, style='surface', selected_color='pink', indices=None)

Add one or many sphere widgets to a scene. Use a sphere widget to control a vertex location.

Parameters
  • callback (callable) – The function to call back when the widget is modified. It takes a single argument: the center of the sphere as a XYZ coordinate.

  • center (tuple(float)) – Length 3 array for the XYZ coordinate of the sphere’s center when placing it in the scene. If more than one location is passed, then that many widgets will be added and the callback will also be passed the integer index of that widget.

  • radius (float) – The radius of the sphere

  • theta_resolution (int , optional) – Set the number of points in the longitude direction (ranging from start_theta to end theta).

  • phi_resolution (int, optional) – Set the number of points in the latitude direction (ranging from start_phi to end_phi).

  • color (str) – The color of the sphere’s surface

  • style (str) – Reprsentation style: surface or wireframe

  • selected_color (str) – Color of the widget when selected during interaction

add_spline_widget(callback, bounds=None, factor=1.25, n_hanldes=5, resolution=25, color='yellow', show_ribbon=False, ribbon_color='pink', ribbon_opacity=0.5, **kwargs)

Create and add a spline widget to the scene. Use the bounds argument to place this widget. Several “handles” are used to control a parametric function for building this spline. Click directly on the line to translate the widget.

Note

This widget has trouble displaying certain colors. Use only simple colors (white, black, yellow).

Parameters
  • callback (callable) – The method called everytime the spline is updated. This passes a pyvista.PolyData object to the callback function of the generated spline.

  • bounds (tuple(float)) – Length 6 tuple of the bounding box where the widget is placed.

  • factor (float, optional) – An inflation factor to expand on the bounds when placing

  • n_handles (int) – The number of interactive spheres to control the spline’s parametric function.

  • resolution (int) – The number of points in the spline created between all the handles

  • color (string or 3 item list, optional, defaults to white) – Either a string, rgb list, or hex color string.

  • show_ribbon (bool) – If True, the poly plane used for slicing will also be shown.

add_text(text, position='upper_left', font_size=18, color=None, font=None, shadow=False, name=None, loc=None, viewport=False)

Adds text to plot object in the top left corner by default

Parameters
  • text (str) – The text to add the the rendering

  • position (str, tuple(float)) – Position to place the bottom left corner of the text box. If tuple is used, the position of the text uses the pixel coordinate system (default). In this case, it returns a more general vtkOpenGLTextActor. If string name is used, it returns a vtkCornerAnnotation object normally used for fixed labels (like title or xlabel). Default is to find the top left corner of the renderering window and place text box up there. Available position: 'lower_left', 'lower_right', 'upper_left', 'upper_right', 'lower_edge', 'upper_edge', 'right_edge', and 'left_edge'

  • font (string, optional) – Font name may be courier, times, or arial

  • shadow (bool, optional) – Adds a black shadow to the text. Defaults to False

  • name (str, optional) – The name for the added actor so that it can be easily updated. If an actor of this name already exists in the rendering window, it will be replaced by the new actor.

  • loc (int, tuple, or list) – Index of the renderer to add the actor to. For example, loc=2 or loc=(1, 1).

  • viewport (bool) – If True and position is a tuple of float, uses the normalized viewport coordinate system (values between 0.0 and 1.0 and support for HiDPI).

Returns

textActor – Text actor added to plot

Return type

vtk.vtkTextActor

add_volume(volume, scalars=None, clim=None, resolution=None, opacity='linear', n_colors=256, cmap=None, flip_scalars=False, reset_camera=None, name=None, ambient=0.0, categories=False, loc=None, backface_culling=False, multi_colors=False, blending='composite', mapper='fixed_point', stitle=None, scalar_bar_args=None, show_scalar_bar=None, annotations=None, pickable=True, **kwargs)

Adds a volume, rendered using a fixed point ray cast mapper by default.

Requires a 3D numpy.ndarray or pyvista.UniformGrid.

Parameters
  • volume (3D numpy.ndarray or pyvista.UnformGrid) – The input volume to visualize. 3D numpy arrays are accepted.

  • scalars (str or numpy.ndarray, optional) – Scalars used to “color” the mesh. Accepts a string name of an array that is present on the mesh or an array equal to the number of cells or the number of points in the mesh. Array should be sized as a single vector. If both color and scalars are None, then the active scalars are used.

  • clim (2 item list, optional) – Color bar range for scalars. Defaults to minimum and maximum of scalars array. Example: [-1, 2]. rng is also an accepted alias for this.

  • opacity (string or numpy.ndarray, optional) – Opacity mapping for the scalars array. A string can also be specified to map the scalar range to a predefined opacity transfer function (options include: ‘linear’, ‘linear_r’, ‘geom’, ‘geom_r’). Or you can pass a custum made trasfer function that is an aray either n_colors in length or shorter.

  • n_colors (int, optional) – Number of colors to use when displaying scalars. Defaults to 256. The scalar bar will also have this many colors.

  • flip_scalars (bool, optional) – Flip direction of cmap.

  • n_colors – Number of colors to use when displaying scalars. Default 256.

  • cmap (str, optional) – Name of the Matplotlib colormap to us when mapping the scalars. See available Matplotlib colormaps. Only applicable for when displaying scalars. Requires Matplotlib to be installed. colormap is also an accepted alias for this. If colorcet or cmocean are installed, their colormaps can be specified by name.

  • flip_scalars – Flip direction of cmap. Most colormaps allow *_r suffix to do this as well.

  • reset_camera (bool, optional) – Reset the camera after adding this mesh to the scene

  • name (str, optional) – The name for the added actor so that it can be easily updated. If an actor of this name already exists in the rendering window, it will be replaced by the new actor.

  • ambient (float, optional) – When lighting is enabled, this is the amount of light from 0 to 1 that reaches the actor when not directed at the light source emitted from the viewer. Default 0.0.

  • loc (int, tuple, or list) – Index of the renderer to add the actor to. For example, loc=2 or loc=(1, 1). If None, selects the last active Renderer.

  • backface_culling (bool optional) – Does not render faces that should not be visible to the plotter. This can be helpful for dense surface meshes, especially when edges are visible, but can cause flat meshes to be partially displayed. Default False.

  • categories (bool, optional) – If set to True, then the number of unique values in the scalar array will be used as the n_colors argument.

  • multi_colors (bool, optional) – Whether or not to use multiple colors when plotting MultiBlock object. Blocks will be colored sequentially as ‘Reds’, ‘Greens’, ‘Blues’, and ‘Grays’.

  • blending (str, optional) – Blending mode for visualisation of the input object(s). Can be one of ‘additive’, ‘maximum’, ‘minimum’, ‘composite’, or ‘average’. Defaults to ‘additive’.

  • mapper (str, optional) – Volume mapper to use given by name. Options include: 'fixed_point', 'gpu', 'open_gl', and 'smart'.

  • scalar_bar_args (dict, optional) – Dictionary of keyword arguments to pass when adding the scalar bar to the scene. For options, see pyvista.BasePlotter.add_scalar_bar().

  • show_scalar_bar (bool) – If False, a scalar bar will not be added to the scene. Defaults to True.

  • stitle (string, optional) – Scalar bar title. By default the scalar bar is given a title of the the scalar array used to color the mesh. To create a bar with no title, use an empty string (i.e. ‘’).

  • annotations (dict, optional) – Pass a dictionary of annotations. Keys are the float values in the scalar range to annotate on the scalar bar and the values are the the string annotations.

Returns

actor – VTK volume of the input data.

Return type

vtk.vtkVolume

property background_color

Returns background color of the first render window

property bounds

Returns the bounds of the active renderer

property camera

The active camera of the active renderer

property camera_position

Returns camera position of the active render window

property camera_set

Returns if the camera of the active renderer has been set

property center

Returns the center of the active renderer

clear()

Clears plot by removing all actors and properties

clear_box_widgets()

Disables all of the box widgets

clear_events_for_key(key)
clear_line_widgets()

Disables all of the line widgets

clear_plane_widgets()

Disables all of the plane widgets

clear_slider_widgets()

Disables all of the slider widgets

clear_sphere_widgets()

Disable all of the sphere widgets

clear_spline_widgets()

disables all of the spline widgets

close()

closes render window

deep_clean()
disable()

Disable this renderer’s camera from being interactive

disable_eye_dome_lighting()

Disable eye dome lighting (EDL) for active renderer

disable_parallel_projection()

Reset the camera to use perspective projection.

enable()

Enable this renderer’s camera to be interactive

enable_cell_picking(mesh=None, callback=None, through=True, show=True, show_message=True, style='wireframe', line_width=5, color='pink', font_size=18, **kwargs)

Enables picking of cells. Press “r” to enable retangle based selection. Press “r” again to turn it off. Selection will be saved to self.picked_cells. Also press “p” to pick a single cell under the mouse location.

Uses last input mesh for input by default.

Warning

Visible cell picking (through=False) is known to not perfrom well and produce incorrect selections on non-triangulated meshes if using any grpahics card other than NVIDIA. A warning will be thrown if the mesh is not purely triangles when using visible cell selection.

Parameters
  • mesh (pyvista.Common, optional) – UnstructuredGrid grid to select cells from. Uses last input grid by default.

  • callback (function, optional) – When input, calls this function after a selection is made. The picked_cells are input as the first parameter to this function.

  • through (bool, optional) – When True (default) the picker will select all cells through the mesh. When False, the picker will select only visible cells on the mesh’s surface.

  • show (bool) – Show the selection interactively

  • show_message (bool, str) – Show the message about how to use the cell picking tool. If this is a string, that will be the message shown.

  • kwargs (optional) – All remaining keyword arguments are used to control how the selection is intereactively displayed

enable_eye_dome_lighting()

Enable eye dome lighting (EDL) for active renderer

enable_geodesic_picking(callback=None, show_message=True, font_size=18, color='pink', point_size=10, line_width=5, **kwargs)

This is a conveinance method for enable_point_picking to keep track of the picked points and create a geodesic path using those points.

The geodesic path is saved to the .picked_geodesic attribute of this plotter

enable_horizon_picking(callback=None, normal=(0, 0, 1), width=None, show_message=True, font_size=18, color='pink', point_size=10, line_width=5, show_path=True, opacity=0.75, show_horizon=True, **kwargs)

Helper for the enable_path_picking method to also show a ribbon surface along the picked path.

enable_image_style()

sets the interactive style to image

Controls:
  • Left Mouse button triggers window level events

  • CTRL Left Mouse spins the camera around its view plane normal

  • SHIFT Left Mouse pans the camera

  • CTRL SHIFT Left Mouse dollys (a positional zoom) the camera

  • Middle mouse button pans the camera

  • Right mouse button dollys the camera.

  • SHIFT Right Mouse triggers pick events

enable_joystick_style()

sets the interactive style to joystick

allows the user to move (rotate, pan, etc.) the camera, the point of view for the scene. The position of the mouse relative to the center of the scene determines the speed at which the camera moves, and the speed of the mouse movement determines the acceleration of the camera, so the camera continues to move even if the mouse if not moving.

For a 3-button mouse, the left button is for rotation, the right button for zooming, the middle button for panning, and ctrl + left button for spinning. (With fewer mouse buttons, ctrl + shift + left button is for zooming, and shift + left button is for panning.)

enable_parallel_projection()

Set use parallel projection. The camera will have a parallel projection. Parallel projection is often useful when viewing images or 2D datasets.

enable_path_picking(callback=None, show_message=True, font_size=18, color='pink', point_size=10, line_width=5, show_path=True, **kwargs)

This is a conveinance method for enable_point_picking to keep track of the picked points and create a line using those points.

The line is saved to the .picked_path attribute of this plotter

enable_point_picking(callback=None, show_message=True, font_size=18, color='pink', point_size=10, use_mesh=False, show_point=True, **kwargs)

Enable picking a point at the mouse location in the render view using the P key. This point is saved to the .picked_point attrbute on the plotter. Pass a callback function that takes that point as an argument. The picked point can either be a point on the first intersecting mesh, or a point in the 3D window.

If use_mesh is True, the callback function will be passed a pointer to the picked mesh and the point ID of the selcted mesh.

enable_rubber_band_style()

sets the interactive style to rubber band picking

This interactor style allows the user to draw a rectangle in the render window by hitting ‘r’ and then using the left mouse button. When the mouse button is released, the attached picker operates on the pixel in the center of the selection rectangle. If the picker happens to be a vtkAreaPicker it will operate on the entire selection rectangle. When the ‘p’ key is hit the above pick operation occurs on a 1x1 rectangle. In other respects it behaves the same as its parent class.

enable_terrain_style()

sets the interactive style to terrain

Used to manipulate a camera which is viewing a scene with a natural view up, e.g., terrain. The camera in such a scene is manipulated by specifying azimuth (angle around the view up vector) and elevation (the angle from the horizon).

enable_trackball_style()

sets the interactive style to trackball - the default syle

enable_zoom_style()

sets the interactive style to rubber band zoom

This interactor style allows the user to draw a rectangle in the render window using the left mouse button. When the mouse button is released, the current camera zooms by an amount determined from the shorter side of the drawn rectangle.

export_obj(filename)

Export scene to OBJ format

export_vtkjs(filename, compress_arrays=False)

Export the current rendering scene as a VTKjs scene for rendering in a web browser

fly_to(point)

Given a position point, move the current camera’s focal point to that point. The movement is animated over the number of frames specified in NumberOfFlyFrames. The LOD desired frame rate is used.

generate_orbital_path(factor=3.0, n_points=20, viewup=None, shift=0.0)

Genrates an orbital path around the data scene

Parameters
  • factor (float) – A scaling factor when biulding the orbital extent

  • n_points (int) – number of points on the orbital path

  • viewup (list(float)) – the normal to the orbital plane

  • shift (float, optional) – shift the plane up/down from the center of the scene by this amount

get_default_cam_pos(negative=False)

Return the default camera position of the active renderer

get_image_depth(fill_value=nan, reset_camera_clipping_range=True)

Returns a depth image representing current render window

Parameters
  • fill_value (float) – Fill value for points in image that don’t include objects in scene. To not use a fill value, pass None.

  • reset_camera_clipping_range (bool) – Reset the camera clipping range to include data in view?

Returns

image_depth – Image of depth values from camera orthogonal to image plane

Return type

numpy.ndarray

Notes

Values in image_depth are negative to adhere to a right-handed coordinate system.

get_pick_position()

Get the pick position/area as x0, y0, x1, y1

hide_axes()

Hide the axes orientation widget

property image

Returns an image array of current render window

property image_depth

Helper attribute for get_image_depth

index_to_loc(index)

Convert a 1D index location to the 2D location on the plotting grid

isometric_view()

DEPRECATED: Please use view_isometric

isometric_view_interactive()

sets the current interactive render window to isometric view

key_press_event(obj, event)

Listens for key press event

left_button_down(obj, event_type)

Register the event for a left button down click

property length

Returns the length of the diagonal of the bounding box of the scene

Links the views’ cameras.

Parameters

views (int | tuple or list) – If views is int, link the views to the given view index or if views is a tuple or a list, link the given views cameras.

loc_to_index(loc)

Return index of the render window given a location index.

Parameters

loc (int, tuple, or list) – Index of the renderer to add the actor to. For example, loc=2 or loc=(1, 1).

Returns

idx – Index of the render window.

Return type

int

open_gif(filename)

Open a gif file.

Parameters

filename (str) – Filename of the gif to open. Filename must end in gif.

open_movie(filename, framerate=24)

Establishes a connection to the ffmpeg writer

Parameters
  • filename (str) – Filename of the movie to open. Filename should end in mp4, but other filetypes may be supported. See “imagio.get_writer”

  • framerate (int, optional) – Frames per second.

orbit_on_path(path=None, focus=None, step=0.5, viewup=None, bkg=True, write_frames=False)

Orbit on the given path focusing on the focus point

Parameters
  • path (pyvista.PolyData) – Path of orbital points. The order in the points is the order of travel

  • focus (list(float) of length 3, optional) – The point ot focus the camera.

  • step (float, optional) – The timestep between flying to each camera position

  • viewup (list(float)) – the normal to the orbital plane

  • write_frames (bool) – Assume a file is open and write a frame on each camera view during the orbit.

remove_actor(actor, reset_camera=False)

Removes an actor from the Plotter.

Parameters
  • actor (vtk.vtkActor) – Actor that has previously added to the Renderer.

  • reset_camera (bool, optional) – Resets camera so all actors can be seen.

Returns

success – True when actor removed. False when actor has not been removed.

Return type

bool

remove_bounding_box(loc=None)

Removes bounding box from the active renderer.

Parameters

loc (int, tuple, or list) – Index of the renderer to add the actor to. For example, loc=2 or loc=(1, 1). If None, selects the last active Renderer.

remove_bounds_axes(loc=None)

Removes bounds axes from the active renderer.

Parameters

loc (int, tuple, or list) – Index of the renderer to add the actor to. For example, loc=2 or loc=(1, 1). If None, selects the last active Renderer.

remove_legend()

Removes legend actor

remove_scalar_bar()

Removes scalar bar

property renderer

simply returns the active renderer

reset_camera()

Reset camera so it slides along the vector defined from camera position to focal point until all of the actors can be seen.

reset_key_events()

Reset all of the key press events to their defaults.

property scale

The scaling of the active renderer.

screenshot(filename=None, transparent_background=None, return_img=None, window_size=None)

Takes screenshot at current camera position

Parameters
  • filename (str, optional) – Location to write image to. If None, no image is written.

  • transparent_background (bool, optional) – Makes the background transparent. Default False.

  • return_img (bool, optional) – If a string filename is given and this is true, a NumPy array of the image will be returned.

Returns

img – Array containing pixel RGB and alpha. Sized: [Window height x Window width x 3] for transparent_background=False [Window height x Window width x 4] for transparent_background=True

Return type

numpy.ndarray

Examples

>>> import pyvista
>>> sphere = pyvista.Sphere()
>>> plotter = pyvista.Plotter()
>>> actor = plotter.add_mesh(sphere)
>>> plotter.screenshot('screenshot.png') 
set_background(color, loc='all')

Sets background color

Parameters
  • color (string or 3 item list, optional, defaults to white) –

    Either a string, rgb list, or hex color string. For example:

    color=’white’ color=’w’ color=[1, 1, 1] color=’#FFFFFF’

  • loc (int, tuple, list, or str, optional) – Index of the renderer to add the actor to. For example, loc=2 or loc=(1, 1). If loc='all' then all render windows will have their background set.

set_focus(point)

sets focus to a point

set_position(point, reset=False)

sets camera position to a point

set_scale(xscale=None, yscale=None, zscale=None, reset_camera=True)

Scale all the datasets in the scene of the active renderer.

Scaling in performed independently on the X, Y and Z axis. A scale of zero is illegal and will be replaced with one.

Parameters
  • xscale (float, optional) – Scaling of the x axis. Must be greater than zero.

  • yscale (float, optional) – Scaling of the y axis. Must be greater than zero.

  • zscale (float, optional) – Scaling of the z axis. Must be greater than zero.

  • reset_camera (bool, optional) – Resets camera so all actors can be seen.

set_viewup(vector)

sets camera viewup vector

show_axes()

Show the axes orientation widget

show_bounds(mesh=None, bounds=None, show_xaxis=True, show_yaxis=True, show_zaxis=True, show_xlabels=True, show_ylabels=True, show_zlabels=True, italic=False, bold=True, shadow=False, font_size=None, font_family=None, color=None, xlabel='X Axis', ylabel='Y Axis', zlabel='Z Axis', use_2d=False, grid=None, location='closest', ticks=None, all_edges=False, corner_factor=0.5, fmt=None, minor_ticks=False, loc=None, padding=0.0)

Adds bounds axes. Shows the bounds of the most recent input mesh unless mesh is specified.

Parameters
  • mesh (vtkPolydata or unstructured grid, optional) – Input mesh to draw bounds axes around

  • bounds (list or tuple, optional) – Bounds to override mesh bounds. [xmin, xmax, ymin, ymax, zmin, zmax]

  • show_xaxis (bool, optional) – Makes x axis visible. Default True.

  • show_yaxis (bool, optional) – Makes y axis visible. Default True.

  • show_zaxis (bool, optional) – Makes z axis visible. Default True.

  • show_xlabels (bool, optional) – Shows x labels. Default True.

  • show_ylabels (bool, optional) – Shows y labels. Default True.

  • show_zlabels (bool, optional) – Shows z labels. Default True.

  • italic (bool, optional) – Italicises axis labels and numbers. Default False.

  • bold (bool, optional) – Bolds axis labels and numbers. Default True.

  • shadow (bool, optional) – Adds a black shadow to the text. Default False.

  • font_size (float, optional) – Sets the size of the label font. Defaults to 16.

  • font_family (string, optional) – Font family. Must be either courier, times, or arial.

  • color (string or 3 item list, optional) –

    Color of all labels and axis titles. Default white. Either a string, rgb list, or hex color string. For example:

    color=’white’ color=’w’ color=[1, 1, 1] color=’#FFFFFF’

  • xlabel (string, optional) – Title of the x axis. Default “X Axis”

  • ylabel (string, optional) – Title of the y axis. Default “Y Axis”

  • zlabel (string, optional) – Title of the z axis. Default “Z Axis”

  • use_2d (bool, optional) – A bug with vtk 6.3 in Windows seems to cause this function to crash this can be enabled for smoother plotting for other enviornments.

  • grid (bool or str, optional) – Add grid lines to the backface (True, 'back', or 'backface') or to the frontface ('front', 'frontface') of the axes actor.

  • location (str, optional) – Set how the axes are drawn: either static ('all'), closest triad (front), furthest triad ('back'), static closest to the origin ('origin'), or outer edges ('outer') in relation to the camera position. Options include: 'all', 'front', 'back', 'origin', 'outer'

  • ticks (str, optional) – Set how the ticks are drawn on the axes grid. Options include: 'inside', 'outside', 'both'

  • all_edges (bool, optional) – Adds an unlabeled and unticked box at the boundaries of plot. Useful for when wanting to plot outer grids while still retaining all edges of the boundary.

  • corner_factor (float, optional) – If all_edges``, this is the factor along each axis to draw the default box. Dafuault is 0.5 to show the full box.

  • loc (int, tuple, or list) – Index of the renderer to add the actor to. For example, loc=2 or loc=(1, 1). If None, selects the last active Renderer.

  • padding (float, optional) – An optional percent padding along each axial direction to cushion the datasets in the scene from the axes annotations. Defaults to have no padding

Returns

cube_axes_actor – Bounds actor

Return type

vtk.vtkCubeAxesActor

Examples

>>> import pyvista
>>> from pyvista import examples
>>> mesh = pyvista.Sphere()
>>> plotter = pyvista.Plotter()
>>> _ = plotter.add_mesh(mesh)
>>> _ = plotter.show_bounds(grid='front', location='outer', all_edges=True)
>>> plotter.show() 
show_grid(**kwargs)

A wrapped implementation of show_bounds to change default behaviour to use gridlines and showing the axes labels on the outer edges. This is intended to be silimar to matplotlib’s grid function.

subplot(index_row, index_column=None)

Sets the active subplot.

Parameters
  • index_row (int) – Index of the subplot to activate along the rows.

  • index_column (int) – Index of the subplot to activate along the columns.

Unlinks the views’ cameras.

Parameters

views (None | int | tuple or list) – If views is None unlink all the views, if views is int unlink the selected view’s camera or if views is a tuple or a list, unlink the given views cameras.

update(stime=1, force_redraw=True)

Update window, redraw, process messages query

Parameters
  • stime (int, optional) – Duration of timer that interrupt vtkRenderWindowInteractor in milliseconds.

  • force_redraw (bool, optional) – Call vtkRenderWindowInteractor.Render() immediately.

update_bounds_axes()

Update the bounds of the active renderer

update_coordinates(points, mesh=None, render=True)

Updates the points of the an object in the plotter.

Parameters
  • points (np.ndarray) – Points to replace existing points.

  • mesh (vtk.PolyData or vtk.UnstructuredGrid, optional) – Object that has already been added to the Plotter. If None, uses last added mesh.

  • render (bool, optional) – Forces an update to the render window. Default True.

update_scalar_bar_range(clim, name=None)

Update the value range of the active or named scalar bar.

Parameters
  • item list (2) – The new range of scalar bar. Example: [-1, 2].

  • name (str, optional) – The title of the scalar bar to update

update_scalars(scalars, mesh=None, render=True)

Updates scalars of the an object in the plotter.

Parameters
  • scalars (np.ndarray) – Scalars to replace existing scalars.

  • mesh (vtk.PolyData or vtk.UnstructuredGrid, optional) – Object that has already been added to the Plotter. If None, uses last added mesh.

  • render (bool, optional) – Forces an update to the render window. Default True.

update_style()
view_isometric(negative=False)

Resets the camera to a default isometric view showing all the actors in the scene.

view_vector(vector, viewup=None)
view_xy(negative=False)

View the XY plane

view_xz(negative=False)

View the XZ plane

view_yx(negative=False)

View the YX plane

view_yz(negative=False)

View the YZ plane

view_zx(negative=False)

View the ZX plane

view_zy(negative=False)

View the ZY plane

property window_size

returns render window size

write_frame()

Writes a single frame to the movie file

Plotter

Attributes

last_update_time

q_pressed

right_timer_id

Methods

plot(*args, **kwargs)

Present for backwards compatibility.

render()

renders main window

show([title, window_size, interactive, …])

Creates plotting window

class pyvista.Plotter(off_screen=None, notebook=None, shape=(1, 1), border=None, border_color='k', border_width=2.0, window_size=None, multi_samples=None, line_smoothing=False, point_smoothing=False, polygon_smoothing=False, splitting_position=None, title=None)

Bases: pyvista.plotting.plotting.BasePlotter

Plotting object to display vtk meshes or numpy arrays.

Example

>>> import pyvista
>>> from pyvista import examples
>>> mesh = examples.load_hexbeam()
>>> another_mesh = examples.load_uniform()
>>> plotter = pyvista.Plotter()
>>> _ = plotter.add_mesh(mesh, color='red')
>>> _ = plotter.add_mesh(another_mesh, color='blue')
>>> plotter.show() 
Parameters
  • off_screen (bool, optional) – Renders off screen when False. Useful for automated screenshots.

  • notebook (bool, optional) – When True, the resulting plot is placed inline a jupyter notebook. Assumes a jupyter console is active. Automatically enables off_screen.

  • shape (list or tuple, optional) –

    Number of sub-render windows inside of the main window. Specify two across with shape=(2, 1) and a two by two grid with shape=(2, 2). By default there is only one render window. Can also accept a shape as string descriptor. E.g.:

    shape=”3|1” means 3 plots on the left and 1 on the right, shape=”4/2” means 4 plots on top of 2 at bottom.

  • border (bool, optional) – Draw a border around each render window. Default False.

  • border_color (string or 3 item list, optional, defaults to white) –

    Either a string, rgb list, or hex color string. For example:

    color=’white’ color=’w’ color=[1, 1, 1] color=’#FFFFFF’

  • window_size (list, optional) – Window size in pixels. Defaults to [1024, 768]

  • multi_samples (int) – The number of multi-samples used to mitigate aliasing. 4 is a good default but 8 will have better results with a potential impact on perfromance.

  • line_smoothing (bool) – If True, enable line smothing

  • point_smoothing (bool) – If True, enable point smothing

  • polygon_smoothing (bool) – If True, enable polygon smothing

last_update_time = 0.0
plot(*args, **kwargs)

Present for backwards compatibility. Use show() instead

q_pressed = False
render()

renders main window

right_timer_id = -1
show(title=None, window_size=None, interactive=True, auto_close=None, interactive_update=False, full_screen=False, screenshot=False, return_img=False, use_panel=None, cpos=None, height=400)

Creates plotting window

Parameters
  • title (string, optional) – Title of plotting window.

  • window_size (list, optional) – Window size in pixels. Defaults to [1024, 768]

  • interactive (bool, optional) – Enabled by default. Allows user to pan and move figure.

  • auto_close (bool, optional) – Enabled by default. Exits plotting session when user closes the window when interactive is True.

  • interactive_update (bool, optional) – Disabled by default. Allows user to non-blocking draw, user should call Update() in each iteration.

  • full_screen (bool, optional) – Opens window in full screen. When enabled, ignores window_size. Default False.

  • use_panel (bool, optional) – If False, the interactive rendering from panel will not be used in notebooks

  • cpos (list(tuple(floats))) – The camera position to use

  • height (int, optional) – height for panel pane. Only used with panel.

Returns

cpos – List of camera position, focal point, and view up

Return type

list

Renderer

Attributes

bounds

Bounds of all actors present in the rendering window

camera

The active camera for the rendering scene

camera_position

Returns camera position of active render window

center

Center of the bounding box around all data present in the scene

Methods

add_actor(uinput[, reset_camera, name, loc, …])

Adds an actor to render window.

add_axes_at_origin([x_color, y_color, …])

Add axes actor at origin

add_border([color, width])

add_bounding_box([color, corner_factor, …])

Adds an unlabeled and unticked box at the boundaries of plot.

add_bounds_axes(*args, **kwargs)

Deprecated

deep_clean()

disable()

Disable this renderer’s camera from being interactive

disable_eye_dome_lighting()

Disable eye dome lighting (EDL)

disable_parallel_projection()

Reset the camera to use perspective projection.

enable()

Enable this renderer’s camera to be interactive

enable_eye_dome_lighting()

Enable eye dome lighting (EDL)

enable_parallel_projection()

Set use parallel projection.

get_default_cam_pos([negative])

Returns the default focal points and viewup.

get_pick_position()

Get the pick position/area as x0, y0, x1, y1

isometric_view()

DEPRECATED: Please use view_isometric

remove_actor(actor[, reset_camera])

Removes an actor from the Renderer.

remove_bounding_box()

Removes bounding box

remove_bounds_axes()

Removes bounds axes

reset_camera()

Reset camera so it slides along the vector defined from camera position to focal point until all of the actors can be seen.

set_scale([xscale, yscale, zscale, reset_camera])

Scale all the datasets in the scene.

show_bounds([mesh, bounds, show_xaxis, …])

Adds bounds axes.

update_bounds_axes()

Update the bounds axes of the render window

view_isometric([negative])

Resets the camera to a default isometric view showing all the actors in the scene.

view_vector(vector[, viewup])

Point the camera in the direction of the given vector

view_xy([negative])

View the XY plane

view_xz([negative])

View the XZ plane

view_yx([negative])

View the YX plane

view_yz([negative])

View the YZ plane

view_zx([negative])

View the ZX plane

view_zy([negative])

View the ZY plane

class pyvista.Renderer(parent, border=True, border_color=(1, 1, 1), border_width=2.0)

Bases: vtkRenderingCorePython.vtkRenderer

add_actor(uinput, reset_camera=False, name=None, loc=None, culling=False, pickable=True)

Adds an actor to render window. Creates an actor if input is a mapper.

Parameters
  • uinput (vtk.vtkMapper or vtk.vtkActor) – vtk mapper or vtk actor to be added.

  • reset_camera (bool, optional) – Resets the camera when true.

  • loc (int, tuple, or list) – Index of the renderer to add the actor to. For example, loc=2 or loc=(1, 1).

  • culling (bool optional) – Does not render faces that should not be visible to the plotter. This can be helpful for dense surface meshes, especially when edges are visible, but can cause flat meshes to be partially displayed. Default False.

Returns

  • actor (vtk.vtkActor) – The actor.

  • actor_properties (vtk.Properties) – Actor properties.

add_axes_at_origin(x_color=None, y_color=None, z_color=None, xlabel='X', ylabel='Y', zlabel='Z', line_width=2, labels_off=False)

Add axes actor at origin

Returns

marker_actor – vtkAxesActor actor

Return type

vtk.vtkAxesActor

add_border(color=[1, 1, 1], width=2.0)
add_bounding_box(color=None, corner_factor=0.5, line_width=None, opacity=1.0, render_lines_as_tubes=False, lighting=None, reset_camera=None)

Adds an unlabeled and unticked box at the boundaries of plot. Useful for when wanting to plot outer grids while still retaining all edges of the boundary.

Parameters

corner_factor (float, optional) – If all_edges, this is the factor along each axis to draw the default box. Dafuault is 0.5 to show the full box.

add_bounds_axes(*args, **kwargs)

Deprecated

property bounds

Bounds of all actors present in the rendering window

property camera

The active camera for the rendering scene

property camera_position

Returns camera position of active render window

property center

Center of the bounding box around all data present in the scene

deep_clean()
disable()

Disable this renderer’s camera from being interactive

disable_eye_dome_lighting()

Disable eye dome lighting (EDL)

disable_parallel_projection()

Reset the camera to use perspective projection.

enable()

Enable this renderer’s camera to be interactive

enable_eye_dome_lighting()

Enable eye dome lighting (EDL)

enable_parallel_projection()

Set use parallel projection. The camera will have a parallel projection. Parallel projection is often useful when viewing images or 2D datasets.

get_default_cam_pos(negative=False)

Returns the default focal points and viewup. Uses ResetCamera to make a useful view.

get_pick_position()

Get the pick position/area as x0, y0, x1, y1

isometric_view()

DEPRECATED: Please use view_isometric

remove_actor(actor, reset_camera=False)

Removes an actor from the Renderer.

Parameters
  • actor (vtk.vtkActor) – Actor that has previously added to the Renderer.

  • reset_camera (bool, optional) – Resets camera so all actors can be seen.

Returns

success – True when actor removed. False when actor has not been removed.

Return type

bool

remove_bounding_box()

Removes bounding box

remove_bounds_axes()

Removes bounds axes

reset_camera()

Reset camera so it slides along the vector defined from camera position to focal point until all of the actors can be seen.

set_scale(xscale=None, yscale=None, zscale=None, reset_camera=True)

Scale all the datasets in the scene. Scaling in performed independently on the X, Y and Z axis. A scale of zero is illegal and will be replaced with one.

show_bounds(mesh=None, bounds=None, show_xaxis=True, show_yaxis=True, show_zaxis=True, show_xlabels=True, show_ylabels=True, show_zlabels=True, italic=False, bold=True, shadow=False, font_size=None, font_family=None, color=None, xlabel='X Axis', ylabel='Y Axis', zlabel='Z Axis', use_2d=False, grid=None, location='closest', ticks=None, all_edges=False, corner_factor=0.5, loc=None, fmt=None, minor_ticks=False, padding=0.0)

Adds bounds axes. Shows the bounds of the most recent input mesh unless mesh is specified.

Parameters
  • mesh (vtkPolydata or unstructured grid, optional) – Input mesh to draw bounds axes around

  • bounds (list or tuple, optional) – Bounds to override mesh bounds. [xmin, xmax, ymin, ymax, zmin, zmax]

  • show_xaxis (bool, optional) – Makes x axis visible. Default True.

  • show_yaxis (bool, optional) – Makes y axis visible. Default True.

  • show_zaxis (bool, optional) – Makes z axis visible. Default True.

  • show_xlabels (bool, optional) – Shows x labels. Default True.

  • show_ylabels (bool, optional) – Shows y labels. Default True.

  • show_zlabels (bool, optional) – Shows z labels. Default True.

  • italic (bool, optional) – Italicises axis labels and numbers. Default False.

  • bold (bool, optional) – Bolds axis labels and numbers. Default True.

  • shadow (bool, optional) – Adds a black shadow to the text. Default False.

  • font_size (float, optional) – Sets the size of the label font. Defaults to 16.

  • font_family (string, optional) – Font family. Must be either courier, times, or arial.

  • color (string or 3 item list, optional) –

    Color of all labels and axis titles. Default white. Either a string, rgb list, or hex color string. For example:

    color=’white’ color=’w’ color=[1, 1, 1] color=’#FFFFFF’

  • xlabel (string, optional) – Title of the x axis. Default “X Axis”

  • ylabel (string, optional) – Title of the y axis. Default “Y Axis”

  • zlabel (string, optional) – Title of the z axis. Default “Z Axis”

  • use_2d (bool, optional) – A bug with vtk 6.3 in Windows seems to cause this function to crash this can be enabled for smoother plotting for other enviornments.

  • grid (bool or str, optional) – Add grid lines to the backface (True, 'back', or 'backface') or to the frontface ('front', 'frontface') of the axes actor.

  • location (str, optional) – Set how the axes are drawn: either static ('all'), closest triad (front), furthest triad ('back'), static closest to the origin ('origin'), or outer edges ('outer') in relation to the camera position. Options include: 'all', 'front', 'back', 'origin', 'outer'

  • ticks (str, optional) – Set how the ticks are drawn on the axes grid. Options include: 'inside', 'outside', 'both'

  • all_edges (bool, optional) – Adds an unlabeled and unticked box at the boundaries of plot. Useful for when wanting to plot outer grids while still retaining all edges of the boundary.

  • corner_factor (float, optional) – If all_edges``, this is the factor along each axis to draw the default box. Dafuault is 0.5 to show the full box.

  • loc (int, tuple, or list) – Index of the renderer to add the actor to. For example, loc=2 or loc=(1, 1). If None, selects the last active Renderer.

  • padding (float, optional) – An optional percent padding along each axial direction to cushion the datasets in the scene from the axes annotations. Defaults to have no padding

Returns

cube_axes_actor – Bounds actor

Return type

vtk.vtkCubeAxesActor

Examples

>>> import pyvista
>>> from pyvista import examples
>>> mesh = pyvista.Sphere()
>>> plotter = pyvista.Plotter()
>>> _ = plotter.add_mesh(mesh)
>>> _ = plotter.show_bounds(grid='front', location='outer', all_edges=True)
>>> plotter.show() 
update_bounds_axes()

Update the bounds axes of the render window

view_isometric(negative=False)

Resets the camera to a default isometric view showing all the actors in the scene.

view_vector(vector, viewup=None)

Point the camera in the direction of the given vector

view_xy(negative=False)

View the XY plane

view_xz(negative=False)

View the XZ plane

view_yx(negative=False)

View the YX plane

view_yz(negative=False)

View the YZ plane

view_zx(negative=False)

View the ZX plane

view_zy(negative=False)

View the ZY plane

Plotting in a Jupyter Notebook

Inline plots are possible using a Jupyter notebook. The code snippet below will create a static screenshot of the rendering and display it in the Jupyter notebook:

import pyvista as pv
sphere = pv.Sphere()

# short example
cpos, image = sphere.plot(notebook=True)

# long example
plotter = pv.Plotter(notebook=True)
plotter.add_mesh(sphere)
plotter.show()
../_images/notebook_sphere.png

Jupyter Inline Plotting

To display interactive plots in Jupyter notebooks, use the pyvista.BackgroundPlotter to open a rendering window in the background that you can manipulate in real time from the Jupyter notebook:

import pyvista as pv
from pyvista import examples

dataset = examples.load_uniform()

plotter = pv.BackgroundPlotter()
plotter.add_mesh(dataset)

# Then in another cell, you can add more to the plotter
plotter.show_bounds()

Background Plotting

PyVista provides a plotter that enables users to create a rendering window in the background that remains interactive while the user performs their processing. This creates the ability to make a rendering scene and interactively add or remove datasets from the scene as well as has some useful menu functions for common scene manipulation or export tasks. To get started, try instantiating the pyvista.BackgroundPlotter:

import pyvista as pv
from pyvista import examples

dataset = examples.load_hexbeam()

p = pv.BackgroundPlotter()

p.add_mesh(dataset)

p.show_bounds(grid=True, location='back')

Plot Time Series Data

This example outlines how to plot data where the spatial reference and data values change through time:

from threading import Thread
import time
import numpy as np
import pyvista as pv
from pyvista import examples


globe = examples.load_globe()
globe.point_arrays['scalars'] = np.random.rand(globe.n_points)
globe.set_active_scalar('scalars')


plotter = pv.BackgroundPlotter()
plotter.add_mesh(globe, lighting=False, show_edges=True, texture=True, scalars='scalars')
plotter.view_isometric()

# shrink globe in the background
def shrink():
    for i in range(50):
        globe.points *= 0.95
        # Update scalars
        globe.point_arrays['scalars'] = np.random.rand(globe.n_points)
        time.sleep(0.5)

thread = Thread(target=shrink)
thread.start()
../_images/shrink-globe.gif