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


Python collections.PolyCollection方法代码示例

本文整理汇总了Python中matplotlib.collections.PolyCollection方法的典型用法代码示例。如果您正苦于以下问题:Python collections.PolyCollection方法的具体用法?Python collections.PolyCollection怎么用?Python collections.PolyCollection使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在matplotlib.collections的用法示例。


在下文中一共展示了collections.PolyCollection方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _init

# 需要导入模块: from matplotlib import collections [as 别名]
# 或者: from matplotlib.collections import PolyCollection [as 别名]
def _init(self):
        if True:  # not self._initialized:
            self._set_transform()
            _pivot = self.Q.pivot
            self.Q.pivot = self.pivot[self.labelpos]
            # Hack: save and restore the Umask
            _mask = self.Q.Umask
            self.Q.Umask = ma.nomask
            self.verts = self.Q._make_verts(np.array([self.U]),
                                            np.zeros((1,)))
            self.Q.Umask = _mask
            self.Q.pivot = _pivot
            kw = self.Q.polykw
            kw.update(self.kw)
            self.vector = collections.PolyCollection(
                                        self.verts,
                                        offsets=[(self.X, self.Y)],
                                        transOffset=self.get_transform(),
                                        **kw)
            if self.color is not None:
                self.vector.set_color(self.color)
            self.vector.set_transform(self.Q.get_transform())
            self._initialized = True 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:25,代码来源:quiver.py

示例2: set_offsets

# 需要导入模块: from matplotlib import collections [as 别名]
# 或者: from matplotlib.collections import PolyCollection [as 别名]
def set_offsets(self, xy):
        """
        Set the offsets for the barb polygons.  This saves the offsets passed
        in and actually sets version masked as appropriate for the existing
        U/V data. *offsets* should be a sequence.

        Parameters
        ----------
        offsets : sequence of pairs of floats
        """
        self.x = xy[:, 0]
        self.y = xy[:, 1]
        x, y, u, v = delete_masked_points(self.x.ravel(), self.y.ravel(),
                                          self.u, self.v)
        _check_consistent_shapes(x, y, u, v)
        xy = np.column_stack((x, y))
        mcollections.PolyCollection.set_offsets(self, xy)
        self.stale = True 
开发者ID:Relph1119,项目名称:GraphicDesignPatternByPython,代码行数:20,代码来源:quiver.py

示例3: plot_in_hull

# 需要导入模块: from matplotlib import collections [as 别名]
# 或者: from matplotlib.collections import PolyCollection [as 别名]
def plot_in_hull(p, cloud):
    """
    plot relative to `in_hull` for 2d data
    """
    hull = Delaunay(cloud)

    # plot triangulation
    poly = PolyCollection(hull.points[hull.vertices], facecolors='grey',
                          edgecolors='grey', alpha=0.1)
    plt.clf()
    plt.title('in hull: green, out of hull: red')
    plt.gca().add_collection(poly)
    plt.plot(hull.points[:, 0], hull.points[:, 1], 'o', color='grey',
             alpha=0.2)

    # plot tested points `p` - green are inside hull, red outside
    inside = hull.find_simplex(p) >= 0
    plt.plot(p[inside, 0], p[inside, 1], 'og')
    plt.plot(p[~inside, 0], p[~inside, 1], 'or')
    plt.show() 
开发者ID:kklmn,项目名称:xrt,代码行数:22,代码来源:convexHull.py

示例4: _draw_polygons

# 需要导入模块: from matplotlib import collections [as 别名]
# 或者: from matplotlib.collections import PolyCollection [as 别名]
def _draw_polygons(polygons, ax, quickdraw = False, **kwargs):
    """ This function uses a trick where all polygon points are concatenated,
    separated only by NaN values.  This speeds up drawing considerably, see
    http://exnumerus.blogspot.com/2011/02/how-to-quickly-plot-polygons-in.html
    """
    coll = PolyCollection(polygons, **kwargs)
    ax.add_collection(coll)
    stacked_polygons = np.vstack(polygons)
    xmin,ymin = np.min(stacked_polygons, axis = 0)
    xmax,ymax = np.max(stacked_polygons, axis = 0)
    bbox = [xmin,ymin,xmax,ymax]
    return bbox 
开发者ID:amccaugh,项目名称:phidl,代码行数:14,代码来源:quickplotter.py

示例5: draw

# 需要导入模块: from matplotlib import collections [as 别名]
# 或者: from matplotlib.collections import PolyCollection [as 别名]
def draw(self, renderer):
        self._init()
        if (self._new_UV or self.angles == 'xy'
                or self.scale_units in ['x', 'y', 'xy']):
            verts = self._make_verts(self.U, self.V)
            self.set_verts(verts, closed=False)
            self._new_UV = False
        collections.PolyCollection.draw(self, renderer) 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:10,代码来源:quiver.py

示例6: set_offsets

# 需要导入模块: from matplotlib import collections [as 别名]
# 或者: from matplotlib.collections import PolyCollection [as 别名]
def set_offsets(self, xy):
        """
        Set the offsets for the barb polygons.  This saves the offets passed in
        and actually sets version masked as appropriate for the existing U/V
        data. *offsets* should be a sequence.

        ACCEPTS: sequence of pairs of floats
        """
        self.x = xy[:, 0]
        self.y = xy[:, 1]
        x, y, u, v = delete_masked_points(self.x.ravel(), self.y.ravel(),
                                          self.u, self.v)
        xy = np.hstack((x[:, np.newaxis], y[:, np.newaxis]))
        collections.PolyCollection.set_offsets(self, xy) 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:16,代码来源:quiver.py

示例7: add_collection3d

# 需要导入模块: from matplotlib import collections [as 别名]
# 或者: from matplotlib.collections import PolyCollection [as 别名]
def add_collection3d(self, col, zs=0, zdir='z'):
        '''
        Add a 3D collection object to the plot.

        2D collection types are converted to a 3D version by
        modifying the object and adding z coordinate information.

        Supported are:
            - PolyCollection
            - LineColleciton
            - PatchCollection
        '''
        zvals = np.atleast_1d(zs)
        if len(zvals) > 0 :
            zsortval = min(zvals)
        else :
            zsortval = 0   # FIXME: Fairly arbitrary. Is there a better value?

        # FIXME: use issubclass() (although, then a 3D collection
        #       object would also pass.)  Maybe have a collection3d
        #       abstract class to test for and exclude?
        if type(col) is mcoll.PolyCollection:
            art3d.poly_collection_2d_to_3d(col, zs=zs, zdir=zdir)
            col.set_sort_zpos(zsortval)
        elif type(col) is mcoll.LineCollection:
            art3d.line_collection_2d_to_3d(col, zs=zs, zdir=zdir)
            col.set_sort_zpos(zsortval)
        elif type(col) is mcoll.PatchCollection:
            art3d.patch_collection_2d_to_3d(col, zs=zs, zdir=zdir)
            col.set_sort_zpos(zsortval)

        Axes.add_collection(self, col) 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:34,代码来源:axes3d.py

示例8: test_polycollection_joinstyle

# 需要导入模块: from matplotlib import collections [as 别名]
# 或者: from matplotlib.collections import PolyCollection [as 别名]
def test_polycollection_joinstyle():
    # Bug #2890979 reported by Matthew West

    from matplotlib import collections as mcoll

    fig = plt.figure()
    ax = fig.add_subplot(111)
    verts = np.array([[1, 1], [1, 2], [2, 2], [2, 1]])
    c = mcoll.PolyCollection([verts], linewidths=40)
    ax.add_collection(c)
    ax.set_xbound(0, 3)
    ax.set_ybound(0, 3) 
开发者ID:miloharper,项目名称:neural-network-animation,代码行数:14,代码来源:test_axes.py

示例9: test_polycollection_close

# 需要导入模块: from matplotlib import collections [as 别名]
# 或者: from matplotlib.collections import PolyCollection [as 别名]
def test_polycollection_close():
    from mpl_toolkits.mplot3d import Axes3D

    vertsQuad = [
        [[0., 0.], [0., 1.], [1., 1.], [1., 0.]],
        [[0., 1.], [2., 3.], [2., 2.], [1., 1.]],
        [[2., 2.], [2., 3.], [4., 1.], [3., 1.]],
        [[3., 0.], [3., 1.], [4., 1.], [4., 0.]]]

    fig = plt.figure()
    ax = Axes3D(fig)

    colors = ['r', 'g', 'b', 'y', 'k']
    zpos = list(range(5))

    poly = mcollections.PolyCollection(
        vertsQuad * len(zpos), linewidth=0.25)
    poly.set_alpha(0.7)

    ## need to have a z-value for *each* polygon = element!
    zs = []
    cs = []
    for z, c in zip(zpos, colors):
        zs.extend([z] * len(vertsQuad))
        cs.extend([c] * len(vertsQuad))

    poly.set_color(cs)

    ax.add_collection3d(poly, zs=zs, zdir='y')

    ## axis limit settings:
    ax.set_xlim3d(0, 4)
    ax.set_zlim3d(0, 3)
    ax.set_ylim3d(0, 4) 
开发者ID:miloharper,项目名称:neural-network-animation,代码行数:36,代码来源:test_collections.py

示例10: _init

# 需要导入模块: from matplotlib import collections [as 别名]
# 或者: from matplotlib.collections import PolyCollection [as 别名]
def _init(self):
        if True:  # not self._initialized:
            if not self.Q._initialized:
                self.Q._init()
            self._set_transform()
            _pivot = self.Q.pivot
            self.Q.pivot = self.pivot[self.labelpos]
            # Hack: save and restore the Umask
            _mask = self.Q.Umask
            self.Q.Umask = ma.nomask
            self.verts = self.Q._make_verts(np.array([self.U]),
                                            np.zeros((1,)))
            self.Q.Umask = _mask
            self.Q.pivot = _pivot
            kw = self.Q.polykw
            kw.update(self.kw)
            self.vector = mcollections.PolyCollection(
                                        self.verts,
                                        offsets=[(self.X, self.Y)],
                                        transOffset=self.get_transform(),
                                        **kw)
            if self.color is not None:
                self.vector.set_color(self.color)
            self.vector.set_transform(self.Q.get_transform())
            self.vector.set_figure(self.get_figure())
            self._initialized = True 
开发者ID:miloharper,项目名称:neural-network-animation,代码行数:28,代码来源:quiver.py

示例11: remove

# 需要导入模块: from matplotlib import collections [as 别名]
# 或者: from matplotlib.collections import PolyCollection [as 别名]
def remove(self):
        """
        Overload the remove method
        """
        # disconnect the call back
        self.ax.figure.callbacks.disconnect(self._cid)
        self._cid = None
        # pass the remove call up the stack
        mcollections.PolyCollection.remove(self) 
开发者ID:miloharper,项目名称:neural-network-animation,代码行数:11,代码来源:quiver.py

示例12: set_offsets

# 需要导入模块: from matplotlib import collections [as 别名]
# 或者: from matplotlib.collections import PolyCollection [as 别名]
def set_offsets(self, xy):
        """
        Set the offsets for the barb polygons.  This saves the offets passed in
        and actually sets version masked as appropriate for the existing U/V
        data. *offsets* should be a sequence.

        ACCEPTS: sequence of pairs of floats
        """
        self.x = xy[:, 0]
        self.y = xy[:, 1]
        x, y, u, v = delete_masked_points(self.x.ravel(), self.y.ravel(),
                                          self.u, self.v)
        xy = np.hstack((x[:, np.newaxis], y[:, np.newaxis]))
        mcollections.PolyCollection.set_offsets(self, xy) 
开发者ID:miloharper,项目名称:neural-network-animation,代码行数:16,代码来源:quiver.py

示例13: _init

# 需要导入模块: from matplotlib import collections [as 别名]
# 或者: from matplotlib.collections import PolyCollection [as 别名]
def _init(self):
        if True:  # not self._initialized:
            if not self.Q._initialized:
                self.Q._init()
            self._set_transform()
            _pivot = self.Q.pivot
            self.Q.pivot = self.pivot[self.labelpos]
            # Hack: save and restore the Umask
            _mask = self.Q.Umask
            self.Q.Umask = ma.nomask
            self.verts = self.Q._make_verts(np.array([self.U]),
                                            np.zeros((1,)),
                                            self.angle)
            self.Q.Umask = _mask
            self.Q.pivot = _pivot
            kw = self.Q.polykw
            kw.update(self.kw)
            self.vector = mcollections.PolyCollection(
                                        self.verts,
                                        offsets=[(self.X, self.Y)],
                                        transOffset=self.get_transform(),
                                        **kw)
            if self.color is not None:
                self.vector.set_color(self.color)
            self.vector.set_transform(self.Q.get_transform())
            self.vector.set_figure(self.get_figure())
            self._initialized = True 
开发者ID:Relph1119,项目名称:GraphicDesignPatternByPython,代码行数:29,代码来源:quiver.py

示例14: draw

# 需要导入模块: from matplotlib import collections [as 别名]
# 或者: from matplotlib.collections import PolyCollection [as 别名]
def draw(self, renderer):
        self._init()
        verts = self._make_verts(self.U, self.V, self.angles)
        self.set_verts(verts, closed=False)
        self._new_UV = False
        mcollections.PolyCollection.draw(self, renderer)
        self.stale = False 
开发者ID:Relph1119,项目名称:GraphicDesignPatternByPython,代码行数:9,代码来源:quiver.py

示例15: add_collection3d

# 需要导入模块: from matplotlib import collections [as 别名]
# 或者: from matplotlib.collections import PolyCollection [as 别名]
def add_collection3d(self, col, zs=0, zdir='z'):
        '''
        Add a 3D collection object to the plot.

        2D collection types are converted to a 3D version by
        modifying the object and adding z coordinate information.

        Supported are:
            - PolyCollection
            - LineCollection
            - PatchCollection
        '''
        zvals = np.atleast_1d(zs)
        if len(zvals) > 0 :
            zsortval = min(zvals)
        else :
            zsortval = 0   # FIXME: Fairly arbitrary. Is there a better value?

        # FIXME: use issubclass() (although, then a 3D collection
        #       object would also pass.)  Maybe have a collection3d
        #       abstract class to test for and exclude?
        if type(col) is mcoll.PolyCollection:
            art3d.poly_collection_2d_to_3d(col, zs=zs, zdir=zdir)
            col.set_sort_zpos(zsortval)
        elif type(col) is mcoll.LineCollection:
            art3d.line_collection_2d_to_3d(col, zs=zs, zdir=zdir)
            col.set_sort_zpos(zsortval)
        elif type(col) is mcoll.PatchCollection:
            art3d.patch_collection_2d_to_3d(col, zs=zs, zdir=zdir)
            col.set_sort_zpos(zsortval)

        super().add_collection(col) 
开发者ID:Relph1119,项目名称:GraphicDesignPatternByPython,代码行数:34,代码来源:axes3d.py


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