本文整理汇总了Python中matplotlib.collections.PolyCollection.norm方法的典型用法代码示例。如果您正苦于以下问题:Python PolyCollection.norm方法的具体用法?Python PolyCollection.norm怎么用?Python PolyCollection.norm使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类matplotlib.collections.PolyCollection
的用法示例。
在下文中一共展示了PolyCollection.norm方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: plot_trimesh2D
# 需要导入模块: from matplotlib.collections import PolyCollection [as 别名]
# 或者: from matplotlib.collections.PolyCollection import norm [as 别名]
def plot_trimesh2D(verts, faces, val=None, cmap=plt.cm.get_cmap(),
vmin=None, vmax=None, mirror=False, **kw):
"""Plot a mesh of triangles, from directly above, without all this
3D stuff.
Input verts N x 3 array of vertex locations
faces M x 3 array of vertex indices for each face
val M list of values for each vertex, used for coloring
cmap colormap, defaulting to current colormap
vmin lower limit for coloring, defaulting to min(val)
vmax upper limit for coloring, defaulting to max(val)
mirror flag for mirror around x=0
Other keyword pairs are passed to PolyCollection
"""
v = array([[verts[ind,:2] for ind in face] for face in faces])
if mirror:
v = r_[v, v * [-1,1]]
if val is not None:
val = array(val)
poly = PolyCollection(v, cmap=cmap, norm=Normalize(clip=True), **kw)
poly.set_array(val)
poly.set_clim(vmin, vmax)
poly.set_facecolors(poly.norm(val))
ax = plt.gca()
ax.add_collection(poly)
ax.axis('image')
if val is not None:
# This magic dohickey is used by colorbar() and clim(), for example
plt.gci._current = poly
plt.draw() # Seems like should be draw_if_interactive(), but that doesn't
# work, for some unexplained reason.
return poly