| 1 |
""" |
| 2 |
.. _background_image_example: |
| 3 |
|
| 4 |
Background Image |
| 5 |
~~~~~~~~~~~~~~~~ |
| 6 |
|
| 7 |
Add a background image with :func:`pyvista.Plotter.add_background_image`. |
| 8 |
|
| 9 |
""" |
| 10 |
|
| 11 |
import pyvista as pv |
| 12 |
from pyvista import examples |
| 13 |
|
| 14 |
# sphinx_gallery_start_ignore |
| 15 |
# background images do not seem to work in interactive mode |
| 16 |
PYVISTA_GALLERY_FORCE_STATIC_IN_DOCUMENT = True |
| 17 |
# sphinx_gallery_end_ignore |
| 18 |
|
| 19 |
# %% |
| 20 |
# Plot an airplane with the map of the earth in the background |
| 21 |
earth_alt = examples.download_topo_global() |
| 22 |
|
| 23 |
pl = pv.Plotter() |
| 24 |
actor = pl.add_mesh(examples.load_airplane(), smooth_shading=True) |
| 25 |
pl.add_background_image(examples.mapfile) |
| 26 |
pl.show() |
| 27 |
|
| 28 |
# %% |
| 29 |
# Plot several earth related plots |
| 30 |
|
| 31 |
pl = pv.Plotter(shape=(2, 2)) |
| 32 |
|
| 33 |
pl.subplot(0, 0) |
| 34 |
pl.add_text('Earth Visible as Map') |
| 35 |
pl.add_background_image(examples.mapfile, as_global=False) |
| 36 |
|
| 37 |
pl.subplot(0, 1) |
| 38 |
pl.add_text('Earth Altitude') |
| 39 |
actor = pl.add_mesh(earth_alt, cmap='gist_earth') |
| 40 |
|
| 41 |
pl.subplot(1, 0) |
| 42 |
topo = examples.download_topo_land() |
| 43 |
actor = pl.add_mesh(topo, cmap='gist_earth') |
| 44 |
pl.add_text('Earth Land Altitude') |
| 45 |
|
| 46 |
pl.subplot(1, 1) |
| 47 |
globe = examples.load_globe() |
| 48 |
texture = examples.load_globe_texture() |
| 49 |
pl.add_text('Earth Visible as Globe') |
| 50 |
pl.add_mesh(globe, texture=texture, smooth_shading=True) |
| 51 |
|
| 52 |
pl.show() |
| 53 |
# %% |
| 54 |
# .. tags:: plot |