screenshot

Plotter.screenshot(filename=None, transparent_background=None, return_img=True, window_size=None)

Take screenshot at current camera position.

Parameters
filenamestr, optional

Location to write image to. If None, no image is written.

transparent_backgroundbool, optional

Whether to make the background transparent. The default is looked up on the plotter’s theme.

return_imgbool, optional

If True (the default), a NumPy array of the image will be returned.

window_size2-length tuple, optional

Set the plotter’s size to this (width, height) before taking the screenshot.

Returns
numpy.ndarray

Array containing pixel RGB and alpha. Sized:

  • [Window height x Window width x 3] if transparent_background is set to False.

  • [Window height x Window width x 4] if transparent_background is set to True.

Examples

>>> import pyvista
>>> sphere = pyvista.Sphere()
>>> plotter = pyvista.Plotter(off_screen=True)
>>> actor = plotter.add_mesh(sphere)
>>> plotter.screenshot('screenshot.png')