当前位置: 首页>>代码示例>>Python>>正文


Python PolyCollection.norm方法代码示例

本文整理汇总了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
开发者ID:rschroll,项目名称:rschroll.github.com,代码行数:45,代码来源:plot3D.py


注:本文中的matplotlib.collections.PolyCollection.norm方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。