| 1 |
""" |
| 2 |
.. _screenshot_example: |
| 3 |
|
| 4 |
Saving Screenshots |
| 5 |
~~~~~~~~~~~~~~~~~~ |
| 6 |
""" |
| 7 |
|
| 8 |
import matplotlib.pyplot as plt |
| 9 |
|
| 10 |
# sphinx_gallery_thumbnail_number = 2 |
| 11 |
import pyvista as pv |
| 12 |
from pyvista import examples |
| 13 |
|
| 14 |
# Get a sample file |
| 15 |
filename = examples.planefile |
| 16 |
mesh = pv.read(filename) |
| 17 |
|
| 18 |
|
| 19 |
# %% |
| 20 |
# You can also take a screenshot without creating an interactive plot window |
| 21 |
# using the :class:`pyvista.Plotter`: |
| 22 |
|
| 23 |
pl = pv.Plotter(off_screen=True) |
| 24 |
pl.add_mesh(mesh, color='orange') |
| 25 |
pl.show(screenshot='airplane.png') |
| 26 |
|
| 27 |
# %% |
| 28 |
# The ``img`` array can be used to plot the screenshot in ``matplotlib``: |
| 29 |
|
| 30 |
plt.imshow(pl.image) |
| 31 |
plt.show() |
| 32 |
# %% |
| 33 |
# .. tags:: plot |