pyvista.Plotter.screenshot#
- Plotter.screenshot(
- filename=None,
- transparent_background=None,
- return_img=True,
- window_size=None,
- scale=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.ndarray
of 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
None
this will use theimage_scale
property 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_background
is set toFalse
.[Window height x Window width x 4] if
transparent_background
is set toTrue
.
Examples
>>> import pyvista as pv >>> sphere = pv.Sphere() >>> plotter = pv.Plotter(off_screen=True) >>> actor = plotter.add_mesh(sphere) >>> plotter.screenshot('screenshot.png')