Пример #1
0
"""
Plot with Opacity
~~~~~~~~~~~~~~~~~

Plot a mesh's scalar array with an opacity transfer funciton or opacity mapping
based on a scalar array.
"""
# sphinx_gallery_thumbnail_number = 2
import pyvista as pv
from pyvista import examples

# Load St Helens DEM and warp the topography
image = examples.download_st_helens()
mesh = image.warp_by_scalar()

###############################################################################
# Global Value
# ++++++++++++
#
# You can also apply a global opacity value to the mesh by passing a single
# float between 0 and 1 which would enable you to see objects behind the mesh:

p = pv.Plotter()
p.add_mesh(
    image.contour(),
    line_width=5,
)
p.add_mesh(mesh, opacity=0.85, color=True)
p.show()

###############################################################################
Пример #2
0
#
# See `Matplotlib's complete list of available colormaps`_,
# `Colorcet's complete list`_, and `cmocean's complete list`_.
#
# .. _Matplotlib's complete list of available colormaps: https://matplotlib.org/tutorials/colors/colormaps.html
# .. _Colorcet's complete list: https://colorcet.holoviz.org/user_guide/index.html
# .. _cmocean's complete list: https://matplotlib.org/cmocean/

###############################################################################
# Custom Made Colormaps
# +++++++++++++++++++++
#
# To get started using a custom colormap, download some data with scalar values to
# plot.

mesh = examples.download_st_helens().warp_by_scalar()
# Add scalar array with range (0, 100) that correlates with elevation
mesh['values'] = pv.plotting.normalize(mesh['Elevation']) * 100

###############################################################################
# Build a custom colormap - here we make a colormap with 5 discrete colors
# and we specify the ranges where those colors fall:

# Define the colors we want to use
blue = np.array([12/256, 238/256, 246/256, 1])
black = np.array([11/256, 11/256, 11/256, 1])
grey = np.array([189/256, 189/256, 189/256, 1])
yellow = np.array([255/256, 247/256, 0/256, 1])
red = np.array([1, 0, 0, 1])

mapping = np.linspace(mesh['values'].min(), mesh['values'].max(), 256)
Пример #3
0
 def test_download_st_helens():
     data = examples.download_st_helens()
     assert data.n_points
Пример #4
0
"""
Extract Array to Table
~~~~~~~~~~~~~~~~~~~~~~
This example will demonstrate how to extract an array from any input data set
to make a :class:`pyvista.Table` of that single data array. Aftwards, we plot
a histogram of that data array.

This example demos :class:`PVGeo.filters.ExtractArray`
"""
from PVGeo.filters import ExtractArray
from pyvista import examples
import matplotlib.pyplot as plt

###############################################################################
# Create input data
dataset = examples.download_st_helens()

###############################################################################
# Construct the filter
filt = ExtractArray()
# Define the array to extract
# Apply the filter on the input
table = filt.apply(dataset, 'Elevation')
print(table)

###############################################################################
plt.hist(table['Elevation'])
Пример #5
0
p = pv.Plotter()
p.add_mesh(mesh, style="wireframe", color="w")
p.add_mesh(line, color="b")
p.show()

###############################################################################
# Run the filter and produce a line plot
mesh.plot_over_line(a, b, resolution=100)

###############################################################################
# Flat Surface
# ++++++++++++
#
# We could also plot the values of a mesh that lies on a flat surface
mesh = examples.download_st_helens()

# Make two points to construct the line between
a = [mesh.center[0], mesh.bounds[2], mesh.bounds[5]]
b = [mesh.center[0], mesh.bounds[3], mesh.bounds[5]]

# Preview how this line intersects this mesh
line = pv.Line(a, b)

p = pv.Plotter()
p.add_mesh(mesh)
p.add_mesh(line, color="white", line_width=10)
p.add_point_labels([a, b], ["A", "B"],
                   font_size=48,
                   point_color="red",
                   text_color="red")
Пример #6
0
 def __init__(self):
     self._example_data = examples.download_st_helens()
     _ExampleLoader.__init__(self)