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:
- 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.ndarrayof 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 - Nonethis will use the- image_scaleproperty on this plotter which defaults to one.
 
- filename
- Returns:
- pyvista.pyvista_ndarray
- Array containing pixel RGB and alpha. Sized: - [Window height x Window width x 3] if - transparent_backgroundis set to- False.
- [Window height x Window width x 4] if - transparent_backgroundis set to- True.
 
 
 - 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')