pyvista.Plotter.screenshot#
- Plotter.screenshot(
 - filename: str | Path | BytesIO | bool | None = None,
 - transparent_background: bool | None = None,
 - return_img: bool = True,
 - window_size: Sequence[int] | None = None,
 - scale: int | None = None,
 Take screenshot at current camera position.
- Parameters:
 - filename
str|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, anumpy.ndarrayof the image will be returned.- window_sizesequence[
int],optional Set the plotter’s size to this
(width, height)before taking the screenshot.- scale
int,optional Set the factor to scale the window size to make a higher resolution image. If
Nonethis will use theimage_scaleproperty on this plotter which defaults to one.
- filename
 - Returns:
 pyvista.pyvista_ndarrayArray containing pixel RGB and alpha. Sized:
[Window height x Window width x 3] if
transparent_backgroundis set toFalse.[Window height x Window width x 4] if
transparent_backgroundis set toTrue.
See also
Examples
>>> import pyvista as pv >>> sphere = pv.Sphere() >>> plotter = pv.Plotter(off_screen=True) >>> actor = plotter.add_mesh(sphere) >>> plotter.screenshot('screenshot.png')