File: screenshot.py

package info (click to toggle)
python-pyvista 0.46.4-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 176,968 kB
  • sloc: python: 94,346; sh: 216; makefile: 70
file content (35 lines) | stat: -rw-r--r-- 685 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
"""
.. _screenshot_example:

Saving Screenshots
~~~~~~~~~~~~~~~~~~
"""

from __future__ import annotations

import matplotlib.pyplot as plt

# sphinx_gallery_thumbnail_number = 2
import pyvista as pv
from pyvista import examples

# Get a sample file
filename = examples.planefile
mesh = pv.read(filename)


# %%
# You can also take a screenshot without creating an interactive plot window
# using the :class:`pyvista.Plotter`:

plotter = pv.Plotter(off_screen=True)
plotter.add_mesh(mesh, color='orange')
plotter.show(screenshot='airplane.png')

# %%
# The ``img`` array can be used to plot the screenshot in ``matplotlib``:

plt.imshow(plotter.image)
plt.show()
# %%
# .. tags:: plot