Пример #1
0
~~~~~~~~~~~~~~~~~~~~~~~~~


Compute normals on a surface.
"""

# sphinx_gallery_thumbnail_number = 2
from pyvista import examples
import numpy as np

###############################################################################
# Computing the normals of a surface is quite easy using
# :class:`pyvista.PolyData`'s :func:`pyvista.PolyDataFilters.compute_normals`
# method.

mesh = examples.download_topo_global()
mesh.plot(cmap="gist_earth", show_scalar_bar=False)

###############################################################################
# Now we have a surface dataset of the globe loaded - unfortunately, the
# dataset shows the globe with a uniform radius which hides topographic relief.
# Using :func:`pyvista.PolyData.compute_normals`, we can compute the normal
# vectors on the globe at all points in the dataset, then use the values given
# in the dataset to warp the surface in the normals direction to create some
# exaggerated topographic relief.

# Compute the normals in-place and use them to warp the globe
mesh.compute_normals(inplace=True)  # this activates the normals as well

# Now use those normals to warp the surface
warp = mesh.warp_by_scalar(factor=0.5e-5)
Пример #2
0
"""
Background Image
~~~~~~~~~~~~~~~~

Add a background image with ``add_background_image``

"""
import pyvista as pv
from pyvista import examples

###############################################################################
# Plot an airplane with the map of the earth in the background
earth_alt = examples.download_topo_global()

pl = pv.Plotter()
actor = pl.add_mesh(examples.load_airplane(), smooth_shading=True)
# pl.add_background_image(examples.mapfile)
pl.plot()

###############################################################################
# Plot several earth related plots

pl = pv.Plotter(shape=(2, 2))

pl.subplot(0, 0)
pl.add_text('Earth Visible as Map')
pl.add_background_image(examples.mapfile, as_global=False)

pl.subplot(0, 1)
pl.add_text('Earth Altitude')
actor = pl.add_mesh(earth_alt, cmap='gist_earth')
Пример #3
0
 def __init__(self):
     self._example_data = examples.download_topo_global()
     _ExampleLoader.__init__(self)