本文整理匯總了Python中matplotlib.pyplot.tricontourf方法的典型用法代碼示例。如果您正苦於以下問題:Python pyplot.tricontourf方法的具體用法?Python pyplot.tricontourf怎麽用?Python pyplot.tricontourf使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類matplotlib.pyplot
的用法示例。
在下文中一共展示了pyplot.tricontourf方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: draw_nodal_values_contourf
# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import tricontourf [as 別名]
def draw_nodal_values_contourf(values, coords, edof, levels=12, title=None, dofs_per_node=None, el_type=None, draw_elements=False):
"""Draws element nodal values as filled contours. Element topologies
supported are triangles, 4-node quads and 8-node quads."""
edof_tri = topo_to_tri(edof)
ax = plt.gca()
ax.set_aspect('equal')
x, y = coords.T
v = np.asarray(values)
plt.tricontourf(x, y, edof_tri - 1, v.ravel(), levels)
if draw_elements:
if dofs_per_node != None and el_type != None:
draw_mesh(coords, edof, dofs_per_node,
el_type, color=(0.2, 0.2, 0.2))
else:
info("dofs_per_node and el_type must be specified to draw the mesh.")
if title != None:
ax.set(title=title)
示例2: plot_gll
# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import tricontourf [as 別名]
def plot_gll(x, y, z, vmin=None, vmax=None):
""" Plots values on 2D unstructured GLL mesh
"""
r = (max(x) - min(x))/(max(y) - min(y))
rx = r/np.sqrt(1 + r**2)
ry = 1/np.sqrt(1 + r**2)
f = plt.figure(figsize=(10*rx, 10*ry))
if vmin is not None and vmax is not None:
p = plt.tricontourf(x, y, z, 125, levels=np.linspace(vmin, vmax, 125))
else:
p = plt.tricontourf(x, y, z, 125)
plt.axis('image')
return f, p
示例3: plot_many_gll
# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import tricontourf [as 別名]
def plot_many_gll(x, y, z, vmin=None, vmax=None):
""" Plots values on big 2D unstructured GLL mesh
(in that case tricontourf does not work)
"""
r = (max(x) - min(x))/(max(y) - min(y))
rx = r/np.sqrt(1 + r**2)
ry = 1/np.sqrt(1 + r**2)
f = plt.figure(figsize=(10*rx, 10*ry))
p = plt.tripcolor(x, y, z, vmin=vmin, vmax=vmax)
plt.axis('image')
return f, p
示例4: test_tricontourf_decreasing_levels
# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import tricontourf [as 別名]
def test_tricontourf_decreasing_levels():
# github issue 5477.
x = [0.0, 1.0, 1.0]
y = [0.0, 0.0, 1.0]
z = [0.2, 0.4, 0.6]
plt.figure()
with pytest.raises(ValueError):
plt.tricontourf(x, y, z, [1.0, 0.0])
示例5: plot
# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import tricontourf [as 別名]
def plot(self):
if self.__numberOfVertices != 3: raise RuntimeError('Plotting only supported in 2D')
matrix = self.testPoints[0:self.iterations, :]
x = matrix[:,0].flat
y = matrix[:,1].flat
z = matrix[:,2].flat
coords = []
acquisitions = []
for triangle in self.queue:
coords.append(triangle.pointIndices)
acquisitions.append(-1 * triangle.acquisitionValue)
plotter.figure()
plotter.tricontourf(x, y, coords, z)
plotter.triplot(x, y, coords, color='white', lw=0.5)
plotter.colorbar()
plotter.figure()
plotter.tripcolor(x, y, coords, acquisitions)
plotter.triplot(x, y, coords, color='white', lw=0.5)
plotter.colorbar()
plotter.show()
示例6: tri_plot
# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import tricontourf [as 別名]
def tri_plot(tri, field, title="", levels=12, savefigs=False,
plt_type="contourf", filename="solution_plot.pdf"):
"""Plot contours over triangulation
Parameters
----------
tri : ndarray (float)
Array with number and nodes coordinates:
`number coordX coordY BCX BCY`
field : ndarray (float)
Array with data to be plotted for each node.
title : string (optional)
Title of the plot.
levels : int (optional)
Number of levels to be used in ``contourf``.
savefigs : bool (optional)
Allow to save the figure.
plt_type : string (optional)
Plot the field as one of the options: ``pcolor`` or
``contourf``
filename : string (optional)
Filename to save the figures.
"""
if plt_type == "pcolor":
disp_plot = plt.tripcolor
elif plt_type == "contourf":
disp_plot = plt.tricontourf
disp_plot(tri, field, levels, shading="gouraud")
plt.title(title)
plt.colorbar(orientation='vertical')
plt.axis("image")
if savefigs:
plt.savefig(filename)
示例7: contour_plot
# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import tricontourf [as 別名]
def contour_plot(self, x_coords, y_coords, f):
import matplotlib.pyplot as plt
"""
Make a contour plot
:param x_coords: x coordinates of points
:param y_coords: y coordinates of points
:param f: Function to use for coloring
:return:
"""
fig = plt.figure()
fig.patch.set_facecolor('white')
ax = fig.gca()
ax.set_aspect('equal')
x_min = np.min(x_coords)
x_max = np.max(x_coords)
y_min = np.min(y_coords)
y_max = np.max(y_coords)
triangles = tri.Triangulation(x_coords, y_coords)
for i in range(9):
sub = plt.subplot(3, 3, i+1)
plt.tricontourf(triangles, f[:, i], cmap='Spectral_r', extend='both')
plt.xlim([x_min, x_max])
plt.ylim([y_min, y_max])
plt.tick_params(axis='both', which='both', bottom='off', top='off', left='off', right='off',
labelbottom='off', labelleft='off')