pyvista.Plotter.screenshot#

Plotter.screenshot(
filename=None,
transparent_background=None,
return_img=True,
window_size=None,
scale=None,
)[source]#

Take screenshot at current camera position.

Parameters:
filenamestr | Path | io.BytesIO, 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, default: True

If True, a numpy.ndarray of the image will be returned.

window_sizesequence[int], optional

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

scaleint, optional

Set the factor to scale the window size to make a higher resolution image. If None this will use the image_scale property on this plotter which defaults to one.

Returns:
pyvista.pyvista_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 as pv
>>> sphere = pv.Sphere()
>>> plotter = pv.Plotter(off_screen=True)
>>> actor = plotter.add_mesh(sphere)
>>> plotter.screenshot('screenshot.png')