pyvista.Plotter#
- class Plotter(*args, **kwargs)[source]#
Plotting object to display vtk meshes or numpy arrays.
- Parameters:
- off_screenbool,
optional
Renders off screen when
True
. Useful for automated screenshots.- notebookbool,
optional
When
True
, the resulting plot is placed inline a jupyter notebook. Assumes a jupyter console is active. Automatically enablesoff_screen
.- shapesequence[
int
],optional
Number of sub-render windows inside of the main window. Specify two across with
shape=(2, 1)
and a two by two grid withshape=(2, 2)
. By default there is only one render window. Can also accept a string descriptor as shape. E.g.:shape="3|1"
means 3 plots on the left and 1 on the right,shape="4/2"
means 4 plots on top and 2 at the bottom.
- borderbool,
optional
Draw a border around each render window.
- border_color
ColorLike
, default: “k” Either a string, rgb list, or hex color string. For example:
color='white'
color='w'
color=[1.0, 1.0, 1.0]
color='#FFFFFF'
- window_sizesequence[
int
],optional
Window size in pixels. Defaults to
[1024, 768]
, unless set differently in the relevant theme’swindow_size
property.- line_smoothingbool, default:
False
If
True
, enable line smoothing.- polygon_smoothingbool, default:
False
If
True
, enable polygon smoothing.- lighting
str
, default: ‘light kit” Lighting to set up for the plotter. Accepted options:
'light kit'
: a vtk Light Kit composed of 5 lights.'three lights'
: illumination using 3 lights.'none'
: no light sources at instantiation.
The default is a
'light kit'
(to be precise, 5 separate lights that act like a Light Kit).- theme
pyvista.plotting.themes.Theme
,optional
Plot-specific theme.
- image_scale
int
,optional
Scale factor when saving screenshots. Image sizes will be the
window_size
multiplied by this scale factor.
- off_screenbool,
Examples
>>> import pyvista as pv >>> mesh = pv.Cube() >>> another_mesh = pv.Sphere() >>> pl = pv.Plotter() >>> actor = pl.add_mesh(mesh, color='red', style='wireframe', line_width=4) >>> actor = pl.add_mesh(another_mesh, color='blue') >>> pl.show()
Methods
Plotter.add_actor
(actor[, reset_camera, ...])Add an actor to render window.
Plotter.add_affine_transform_widget
(actor[, ...])Add a 3D affine transform widget.
Plotter.add_arrows
(cent, direction[, mag])Add arrows to the plotter.
Plotter.add_axes
([interactive, line_width, ...])Add an interactive axes widget in the bottom left corner.
Plotter.add_axes_at_origin
([x_color, ...])Add axes actor at origin.
Plotter.add_background_image
(image_path[, ...])Add a background image to a plot.
Add blurring.
Plotter.add_bounding_box
([color, ...])Add an unlabeled and unticked box at the boundaries of plot.
Plotter.add_box_axes
(*[, interactive, ...])Add an interactive color box axes widget in the bottom left corner.
Plotter.add_box_widget
(callback[, bounds, ...])Add a box widget to the scene.
Add a camera3d widget allow to move the camera.
Add a camera orientation widget to the active renderer.
Plotter.add_chart
(chart, *charts)Add a chart to this renderer.
Plotter.add_checkbox_button_widget
(callback)Add a checkbox button widget to the scene.
Plotter.add_composite
(dataset[, color, ...])Add a composite dataset to the plotter.
Plotter.add_cursor
([bounds, focal_point, color])Add a cursor of a PyVista or VTK dataset to the scene.
Plotter.add_floor
([face, i_resolution, ...])Show a floor mesh.
Plotter.add_key_event
(key, callback)Add a function to callback when the given key is pressed.
Plotter.add_legend
([labels, bcolor, border, ...])Add a legend to render window.
Plotter.add_legend_scale
([...])Annotate the render window with scale and distance information.
Plotter.add_light
(light[, only_active])Add a Light to the scene.
Plotter.add_line_widget
(callback[, bounds, ...])Add a line widget to the scene.
Plotter.add_lines
(lines[, color, width, ...])Add lines to the plotting object.
Plotter.add_logo_widget
([logo, position, ...])Add a logo widget to the top of the viewport.
Plotter.add_measurement_widget
([callback, color])Interactively measure distance with a distance widget.
Plotter.add_mesh
(mesh[, color, style, ...])Add any PyVista/VTK mesh or dataset that PyVista can wrap to the scene.
Plotter.add_mesh_clip_box
(mesh[, invert, ...])Clip a mesh using a box widget.
Plotter.add_mesh_clip_plane
(mesh[, normal, ...])Clip a mesh using a plane widget.
Plotter.add_mesh_isovalue
(mesh[, scalars, ...])Create a contour of a mesh with a slider.
Plotter.add_mesh_slice
(mesh[, normal, ...])Slice a mesh using a plane widget.
Plotter.add_mesh_slice_orthogonal
(mesh[, ...])Slice a mesh with three interactive planes.
Plotter.add_mesh_slice_spline
(mesh[, ...])Slice a mesh with a spline widget.
Plotter.add_mesh_threshold
(mesh[, scalars, ...])Apply a threshold on a mesh with a slider.
Add a geographic north arrow to the scene.
Plotter.add_on_render_callback
(callback[, ...])Add a method to be called post-render.
Plotter.add_orientation_widget
(actor[, ...])Use the given actor in an orientation marker widget.
Plotter.add_plane_widget
(callback[, normal, ...])Add a plane widget to the scene.
Plotter.add_point_labels
(points, labels[, ...])Create a point actor with one label from list labels assigned to each point.
Plotter.add_point_scalar_labels
(points, labels)Label the points from a dataset with the values of their scalars.
Plotter.add_points
(points[, style])Add points to a mesh.
Plotter.add_radio_button_widget
(callback, ...)Add a radio button widget to the scene.
Plotter.add_ruler
(pointa, pointb[, ...])Add ruler.
Plotter.add_scalar_bar
([title, mapper, ...])Create scalar bar using the ranges as set by the last input mesh.
Plotter.add_silhouette
(mesh[, color, ...])Add a silhouette of a PyVista or VTK dataset to the scene.
Plotter.add_slider_widget
(callback, rng[, ...])Add a slider bar widget.
Plotter.add_sphere_widget
(callback[, ...])Add one or many sphere widgets to a scene.
Plotter.add_spline_widget
(callback[, ...])Create and add a spline widget to the scene.
Plotter.add_text
(text[, position, ...])Add text to plot object in the top left corner by default.
Plotter.add_text_slider_widget
(callback, data)Add a text slider bar widget.
Plotter.add_timer_event
(max_steps, duration, ...)Add a function to callback as timer event.
Plotter.add_title
(title[, font_size, color, ...])Add text to the top center of the plot.
Plotter.add_volume
(volume[, scalars, clim, ...])Add a volume, rendered using a smart mapper by default.
Plotter.add_volume_clip_plane
(volume[, ...])Clip a volume using a plane widget.
Clear plot by removing all actors and properties.
Clear actors from all renderers.
Remove all of the box widgets.
Remove all of the button widgets.
Remove all of the camera3d widgets.
Remove all of the camera widgets.
Plotter.clear_events_for_key
(key[, ...])Remove the callbacks associated to the key.
Remove all of the line widgets.
Remove all of the logo widgets.
Remove all of the measurement widgets.
Clear all callback methods previously registered with
render()
.Remove all of the plane widgets.
Remove all of the radio button widgets.
Remove all of the slider widgets.
Remove all of the sphere widgets.
Remove all of the spline widgets.
Close the render window.
Clean the plotter of the memory.
Disable this renderer's camera from being interactive.
Please use
enable_lightkit
, this method has been deprecated.Plotter.disable_anti_aliasing
([all_renderers])Disable anti-aliasing.
Disable depth of field plotting.
Disable depth peeling.
Disable eye dome lighting (EDL).
Disable hidden line removal.
Reset the camera to use perspective projection.
Disable any active picking and remove observers.
Disable shadows.
Disable surface space ambient occlusion (SSAO).
Disable anaglyph stereo rendering.
Enable this renderer's camera to be interactive.
Set the interactive style to 2D.
Plotter.enable_3_lights
([only_active])Enable 3-lights illumination.
Plotter.enable_anti_aliasing
([aa_type, ...])Enable anti-aliasing.
Plotter.enable_block_picking
([callback, side])Enable composite block picking.
Plotter.enable_cell_picking
([callback, ...])Enable picking of cells with a rectangle selection tool.
Set the interactive style to a custom style based on Trackball Camera.
Enable depth of field plotting.
Plotter.enable_depth_peeling
([...])Enable depth peeling to improve rendering of translucent geometry.
Plotter.enable_element_picking
([callback, ...])Select individual elements on a mesh.
Enable eye dome lighting (EDL).
Plotter.enable_fly_to_right_click
([callback])Set the camera to track right click positions.
Plotter.enable_geodesic_picking
([callback, ...])Enable picking at geodesic paths.
Enable hidden line removal.
Plotter.enable_horizon_picking
([callback, ...])Enable horizon picking.
Set the interactive style to Image.
Set the interactive style to Joystick Actor.
Set the interactive style to Joystick Camera.
Plotter.enable_lightkit
([only_active])Enable the default light-kit lighting.
Plotter.enable_mesh_picking
([callback, ...])Enable picking of a mesh.
Enable parallel projection.
Plotter.enable_path_picking
([callback, ...])Enable picking at paths.
Plotter.enable_point_picking
([callback, ...])Enable picking at points under the cursor.
Plotter.enable_rectangle_picking
([callback, ...])Enable rectangle based picking at cells.
Enable rectangle based cell picking through the scene.
Enable rectangle based cell picking on visible surfaces.
Set the interactive style to Rubber Band 2D.
Set the interactive style to Rubber Band Picking.
Enable shadows.
Plotter.enable_ssao
([radius, bias, ...])Enable surface space ambient occlusion (SSAO).
Enable anaglyph stereo rendering.
Enable picking of a point on the surface of a mesh.
Plotter.enable_terrain_style
([...])Set the interactive style to Terrain.
Set the interactive style to Trackball Actor.
Set the interactive style to Trackball Camera.
Set the interactive style to Rubber Band Zoom.
Plotter.export_gltf
(filename[, inline_data, ...])Export the current rendering scene as a glTF file.
Plotter.export_html
(filename)Export this plotter as an interactive scene to a HTML file.
Plotter.export_obj
(filename)Export scene to OBJ format.
Plotter.export_vrml
(filename)Export the current rendering scene as a VRML file.
Plotter.export_vtksz
([filename, format])Export this plotter as a VTK.js OfflineLocalView file.
Plotter.fly_to
(point)Move the current camera's focal point to a position point.
Plotter.fly_to_mouse_position
([focus])Focus on last stored mouse position.
Plotter.generate_orbital_path
([factor, ...])Generate an orbital path around the data scene.
Plotter.get_default_cam_pos
([negative])Return the default focal points and viewup.
Plotter.get_image_depth
([fill_value, ...])Return a depth image representing current render window.
Get the pick position or area.
Hide the axes orientation widget.
Hide the axes orientation widget in all renderers.
Plotter.image_scale_context
([scale])Set the image scale in an isolated context.
Plotter.import_3ds
(filename)Import a 3DS file into the plotter.
Plotter.import_gltf
(filename[, set_camera])Import a glTF file into the plotter.
Plotter.import_obj
(filename[, filename_mtl])Import from .obj wavefront files.
Plotter.import_vrml
(filename)Import a VRML file into the plotter.
Increment point size and line width of all actors.
Reset the camera to a default isometric view.
Set the current interactive render window to isometric view.
Plotter.key_press_event
(*args)Listen for key press event.
Plotter.left_button_down
(*args)Register the event for a left button down click.
Plotter.link_views
([views])Link the views' cameras.
Plotter.open_gif
(filename[, loop, fps, ...])Open a gif file.
Plotter.open_movie
(filename[, framerate, ...])Establish a connection to the ffmpeg writer.
Plotter.orbit_on_path
([path, focus, step, ...])Orbit on the given path focusing on the focus point.
Get corresponding click location in the 3D plot.
Get corresponding mouse location in the 3D plot.
Plotter.remove_actor
(actor[, reset_camera, ...])Remove an actor from the Renderer.
Plotter.remove_all_lights
([only_active])Remove all lights from the scene.
Remove the background image at the current renderer.
Remove a single blurring pass.
Plotter.remove_bounding_box
([render])Remove bounding box.
Remove bounds axes.
Plotter.remove_chart
(chart_or_index)Remove a chart from this renderer.
Remove the environment texture.
Plotter.remove_floors
([clear_kwargs, render])Remove all floor actors.
Plotter.remove_legend
([render])Remove the legend actor.
Plotter.remove_scalar_bar
([title, render])Remove a scalar bar.
Render the main window.
Plotter.reset_camera
([render, bounds])Reset the camera of the active render window.
Reset camera clipping planes.
Reset all of the key press events to their defaults.
Plotter.save_graphic
(filename[, title, ...])Save a screenshot of the rendering window as a graphic file.
Plotter.screenshot
([filename, ...])Take screenshot at current camera position.
Plotter.set_background
(color[, top, right, ...])Set the background color.
Plotter.set_chart_interaction
(interactive[, ...])Set or toggle interaction with charts for the active renderer.
Plotter.set_color_cycler
(color_cycler[, ...])Set or reset the color cycler.
Plotter.set_environment_texture
(texture[, ...])Set the environment texture used for image based lighting.
Plotter.set_focus
(point)Set focus to a point.
Plotter.set_position
(point[, reset, render])Set camera position to a point.
Plotter.set_scale
([xscale, yscale, zscale, ...])Scale all the actors in the scene.
Plotter.set_viewup
(vector[, reset, render])Set camera viewup vector.
Plotter.show
([title, window_size, ...])Display the plotting window.
Show the axes orientation widget.
Show the axes orientation widget in all renderers.
Plotter.show_bounds
([mesh, bounds, ...])Add bounds axes.
Plotter.show_grid
(**kwargs)Show grid lines and bounds axes labels.
Plotter.store_click_position
(*args)Store click position in viewport coordinates.
Plotter.store_mouse_position
(*args)Store mouse position.
Plotter.subplot
(index_row[, index_column])Set the active subplot.
Plotter.track_click_position
([callback, ...])Keep track of the click position.
Keep track of the mouse position.
Plotter.unlink_views
([views])Unlink the views' cameras.
Plotter.untrack_click_position
([side])Stop tracking the click position.
Stop tracking the mouse position.
Plotter.update
([stime, force_redraw])Update window, redraw, process messages query.
Update the bounds axes of the render window.
Plotter.update_coordinates
(points[, mesh, ...])Update the points of an object in the plotter.
Plotter.update_scalar_bar_range
(clim[, name])Update the value range of the active or named scalar bar.
Plotter.update_scalars
(scalars[, mesh, render])Update scalars of an object in the plotter.
Plotter.view_isometric
([negative, render, ...])Reset the camera to a default isometric view.
Plotter.view_vector
(vector[, viewup, ...])Point the camera in the direction of the given vector.
Plotter.view_xy
([negative, render, bounds])View the XY plane.
Plotter.view_xz
([negative, render, bounds])View the XZ plane.
Plotter.view_yx
([negative, render, bounds])View the YX plane.
Plotter.view_yz
([negative, render, bounds])View the YZ plane.
Plotter.view_zx
([negative, render, bounds])View the ZX plane.
Plotter.view_zy
([negative, render, bounds])View the ZY plane.
Plotter.where_is
(name)Return the subplot coordinates of a given actor.
Plotter.window_size_context
([window_size])Set the render window size in an isolated context.
Write a single frame to the movie file.
Plotter.zoom_camera
(value)Zoom of the camera and render.
Attributes
Return the actors of the active renderer.
Return the background color of the active render window.
Return the bounds of the active renderer.
Return the active camera of the active renderer.
Return camera position of the active render window.
Return or set if the camera of the active renderer has been set.
Return the center of the active renderer.
Return an image array of current render window.
Return a depth image representing current render window.
Get or set the scale factor when saving a screenshot.
Legend actor.
Return the length of the diagonal of the bounding box of the scene.
Return plotter meshes.
Return or set parallel projection state of active render window.
Return or set parallel scale of active render window.
Return or set the pickable actors.
Return the picked mesh.
Return the picked block index.
Return the picked cell.
Return the picked cells.
Return the picked mesh.
Return the picked point.
Access the vtkRenderWindow attached to this plotter.
Return the active renderer.
First scalar bar (kept for backwards compatibility).
Scalar bars.
Return the scaling of the active renderer.
Return the shape of the plotter.
Get or set whether to suppress render calls.
Return or set the theme used for this plotter.
Return the render window size in
(width, height)
.