show

Plotter.show(title=None, window_size=None, interactive=True, auto_close=None, interactive_update=False, full_screen=None, screenshot=False, return_img=False, cpos=None, use_ipyvtk=None, jupyter_backend=None, return_viewer=False, return_cpos=None, **kwargs)

Display the plotting window.

Parameters
titlestr, optional

Title of plotting window. Defaults to pyvista.global_theme.title.

window_sizelist, optional

Window size in pixels. Defaults to pyvista.global_theme.window_size.

interactivebool, optional

Enabled by default. Allows user to pan and move figure. Defaults to pyvista.global_theme.interactive.

auto_closebool, optional

Exits plotting session when user closes the window when interactive is True. Defaults to pyvista.global_theme.auto_close.

interactive_updatebool, optional

Disabled by default. Allows user to non-blocking draw, user should call BasePlotter.update() in each iteration.

full_screenbool, optional

Opens window in full screen. When enabled, ignores window_size. Defaults to pyvista.global_theme.full_screen.

screenshotstr or bool, optional

Take a screenshot of the initial state of the plot. If a string, it specifies the path to which the screenshot is saved. If True, the screenshot is returned as an array. Defaults to False. For interactive screenshots it’s recommended to first call show() with auto_close=False to set the scene, then save the screenshot in a separate call to show() or Plotter.screenshot().

return_imgbool

Returns a numpy array representing the last image along with the camera position.

cposlist(tuple(floats))

The camera position. You can also set this with Plotter.camera_position.

use_ipyvtkbool, optional

Deprecated. Instead, set the backend either globally with pyvista.set_jupyter_backend('ipyvtklink') or with backend='ipyvtklink'.

jupyter_backendstr, optional

Jupyter notebook plotting backend to use. One of the following:

  • 'none' : Do not display in the notebook.

  • 'pythreejs' : Show a pythreejs widget

  • 'static' : Display a static figure.

  • 'ipygany' : Show a ipygany widget

  • 'panel' : Show a panel widget.

This can also be set globally with pyvista.set_jupyter_backend().

return_viewerbool, optional

Return the jupyterlab viewer, scene, or display object when plotting with jupyter notebook.

return_cposbool, optional

Return the last camera position from the render window when enabled. Default based on theme setting. See pyvista.themes.DefaultTheme.return_cpos.

**kwargsdict, optional

Developer keyword arguments.

Returns
cposlist

List of camera position, focal point, and view up. Returned only when return_cpos=True or set in the default global or plot theme. Not returned when in a jupyter notebook and return_viewer=True.

imagenp.ndarray

Numpy array of the last image when either return_img=True or screenshot=True is set. Not returned when in a jupyter notebook with return_viewer=True. Optionally contains alpha values. Sized:

  • [Window height x Window width x 3] if the theme sets transparent_background=False.

  • [Window height x Window width x 4] if the theme sets transparent_background=True.

widget

IPython widget when return_viewer=True.

Notes

Please use the q-key to close the plotter as some operating systems (namely Windows) will experience issues saving a screenshot if the exit button in the GUI is pressed.

Examples

Simply show the plot of a mesh.

>>> import pyvista as pv
>>> pl = pv.Plotter()
>>> _ = pl.add_mesh(pv.Cube())
>>> pl.show()
../../../_images/pyvista-Plotter-show-1_00_00.png

Take a screenshot interactively. Screenshot will be of the first image shown, so use the first call with auto_close=False to set the scene before taking the screenshot.

>>> pl = pv.Plotter()
>>> _ = pl.add_mesh(pv.Cube())
>>> pl.show(auto_close=False)  
>>> pl.show(screenshot='my_image.png')  

Display a pythreejs scene within a jupyter notebook

>>> pl.show(jupyter_backend='pythreejs')  

Return a pythreejs scene.

>>> pl.show(jupyter_backend='pythreejs', return_viewer=True)  

Obtain the camera position when using show.

>>> pl = pv.Plotter()
>>> _ = pl.add_mesh(pv.Sphere())
>>> pl.show(return_cpos=True)   
[(2.223005211686484, -0.3126909484828709, 2.4686209867735065),
(0.0, 0.0, 0.0),
(-0.6839951597283509, -0.47207319712073137, 0.5561452310578585)]