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


Python patches.PathPatch方法代码示例

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


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

示例1: ConvertPacth

# 需要导入模块: from matplotlib import patches [as 别名]
# 或者: from matplotlib.patches import PathPatch [as 别名]
def ConvertPacth(self, ax, patch):
        path = patch.get_path()
        lon = []
        lat = []
        for points in path.vertices:
            x, y = points[0], points[1]
            xy_pixels = ax.transData.transform(np.vstack([x, y]).T)
            xpix, ypix = xy_pixels.T
            lon.append(xpix[0])
            lat.append(ypix[0])
        from matplotlib.path import Path
        apath = Path(list(zip(lon, lat)))
        from matplotlib import patches
        apatch = patches.PathPatch(apath, linewidth=1, facecolor='none', edgecolor='k')
        plt.gca().add_patch(apatch)
        return apatch 
开发者ID:flashlxy,项目名称:PyMICAPS,代码行数:18,代码来源:Micaps11Data.py

示例2: poly2patch

# 需要导入模块: from matplotlib import patches [as 别名]
# 或者: from matplotlib.patches import PathPatch [as 别名]
def poly2patch(self, poly2d, closed=False, alpha=1., color=None):
        moves = {'L': Path.LINETO,
                 'C': Path.CURVE4}
        points = [p[:2] for p in poly2d]
        codes = [moves[p[2]] for p in poly2d]
        codes[0] = Path.MOVETO

        if closed:
            points.append(points[0])
            if codes[-1] == 4:
                codes.append(Path.LINETO)
            else:
                codes.append(Path.CLOSEPOLY)

        if color is None:
            color = random_color()

        # print(codes, points)
        return mpatches.PathPatch(
            Path(points, codes),
            facecolor=color if closed else 'none',
            edgecolor=color,  # if not closed else 'none',
            lw=1 if closed else 2 * self.scale, alpha=alpha,
            antialiased=False, snap=True) 
开发者ID:ucbdrive,项目名称:bdd100k,代码行数:26,代码来源:show_labels.py

示例3: draw_wire

# 需要导入模块: from matplotlib import patches [as 别名]
# 或者: from matplotlib.patches import PathPatch [as 别名]
def draw_wire(axis, source, target,
              bend_out=False, bend_in=False, to_tikz=False):
    """
    Draws a wire from source to target using a Bezier curve.
    """
    mid = (target[0], source[1]) if bend_out else (source[0], target[1])
    if to_tikz == "controls":
        cmd = "\\draw {} .. controls {} .. {};\n"
        axis.append(cmd.format(*("({}, {})".format(*point)
                                 for point in [source, mid, target])))
    elif to_tikz:
        out = -90 if not bend_out or source[0] == target[0]\
            else (180 if source[0] > target[0] else 0)
        inp = 90 if not bend_in or source[0] == target[0]\
            else (180 if source[0] < target[0] else 0)
        cmd = "\\draw [out={}, in={}] {{}} to {{}};\n".format(out, inp)
        axis.append(cmd.format(*("({}, {})".format(*point)
                                 for point in [source, target])))
    else:
        path = Path([source, mid, target],
                    [Path.MOVETO, Path.CURVE3, Path.CURVE3])
        axis.add_patch(PathPatch(path, facecolor='none')) 
开发者ID:oxford-quantum-group,项目名称:discopy,代码行数:24,代码来源:drawing.py

示例4: poly2patch

# 需要导入模块: from matplotlib import patches [as 别名]
# 或者: from matplotlib.patches import PathPatch [as 别名]
def poly2patch(self, poly2d, closed=False, alpha=1., color=None):
        moves = {'L': Path.LINETO,
                 'C': Path.CURVE4}
        points = [p[:2] for p in poly2d]
        codes = [moves[p[2]] for p in poly2d]
        codes[0] = Path.MOVETO

        if closed:
            points.append(points[0])
            codes.append(Path.CLOSEPOLY)

        if color is None:
            color = random_color()

        # print(codes, points)
        return mpatches.PathPatch(
            Path(points, codes),
            facecolor=color if closed else 'none',
            edgecolor=color,  # if not closed else 'none',
            lw=1 if closed else 2 * self.scale, alpha=alpha,
            antialiased=False, snap=True) 
开发者ID:ucbdrive,项目名称:3d-vehicle-tracking,代码行数:23,代码来源:show_labels.py

示例5: _add_ends

# 需要导入模块: from matplotlib import patches [as 别名]
# 或者: from matplotlib.patches import PathPatch [as 别名]
def _add_ends(self):
        """
        Create patches from extended ends and add them to the axes.
        """

        del self.extension_patch1
        del self.extension_patch2

        path1, path2 = self.ax.get_axes_locator().get_path_ends()
        fc=mpl.rcParams['axes.facecolor']
        ec=mpl.rcParams['axes.edgecolor']
        linewidths=0.5*mpl.rcParams['axes.linewidth']
        self.extension_patch1 = PathPatch(path1,
                                          fc=fc, ec=ec, lw=linewidths,
                                          zorder=2.,
                                          transform=self.ax.transAxes,
                                          clip_on=False)
        self.extension_patch2 = PathPatch(path2,
                                          fc=fc, ec=ec, lw=linewidths,
                                          zorder=2.,
                                          transform=self.ax.transAxes,
                                          clip_on=False)
        self.ax.add_artist(self.extension_patch1)
        self.ax.add_artist(self.extension_patch2) 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:26,代码来源:colorbar.py

示例6: _draw_powerline_line

# 需要导入模块: from matplotlib import patches [as 别名]
# 或者: from matplotlib.patches import PathPatch [as 别名]
def _draw_powerline_line(self,
                             pos_or_x, pos_or_y,
                             pos_ex_x, pos_ex_y,
                             color, line_style):
        codes = [
            Path.MOVETO,
            Path.LINETO
        ]
        verts = [
            (pos_or_x, pos_or_y),
            (pos_ex_x, pos_ex_y)
        ]
        path = Path(verts, codes)
        patch = patches.PathPatch(path,
                                  color=color,
                                  lw=self._line_color_width,
                                  ls=line_style)
        self.ax.add_patch(patch) 
开发者ID:rte-france,项目名称:Grid2Op,代码行数:20,代码来源:PlotMatplot.py

示例7: peak_plot

# 需要导入模块: from matplotlib import patches [as 别名]
# 或者: from matplotlib.patches import PathPatch [as 别名]
def peak_plot(self, start, end, height, center=None, width_adjust=1.5):
        # uses bezier curves to plot a shape that
        # looks like a peak
        peak_width = float(end - start)
        if center is None:
            center = peak_width / 2 + start
        if width_adjust != 1:
            start -= width_adjust * peak_width / 2
            end += width_adjust * peak_width / 2
            peak_width *= width_adjust

        path_data = [
            (Path.MOVETO, (start, 0)),
            (Path.CURVE4, (start + peak_width / 2, 0)),
            (Path.CURVE4, (start + peak_width * 0.4, height)),
            (Path.CURVE4, (center, height)),
            (Path.CURVE4, (end - peak_width * 0.4, height)),
            (Path.CURVE4, (end - peak_width / 2, 0)),
            (Path.CURVE4, (end, 0))]

        codes, verts = zip(*path_data)
        path = Path(verts, codes)
        return patches.PathPatch(path) 
开发者ID:deeptools,项目名称:pyGenomeTracks,代码行数:25,代码来源:NarrowPeakTrack.py

示例8: text3d

# 需要导入模块: from matplotlib import patches [as 别名]
# 或者: from matplotlib.patches import PathPatch [as 别名]
def text3d(ax, xyz, s, zdir="z", size=None, angle=0, usetex=False, **kwargs):
    '''
    Plots the string 's' on the axes 'ax', with position 'xyz', size 'size',
    and rotation angle 'angle'.  'zdir' gives the axis which is to be treated
    as the third dimension.  usetex is a boolean indicating whether the string
    should be interpreted as latex or not.  Any additional keyword arguments
    are passed on to transform_path.

    Note: zdir affects the interpretation of xyz.
    '''
    x, y, z = xyz
    if zdir == "y":
        xy1, z1 = (x, z), y
    elif zdir == "x":
        xy1, z1 = (y, z), x
    else:
        xy1, z1 = (x, y), z

    text_path = TextPath((0, 0), s, size=size, usetex=usetex)
    trans = Affine2D().rotate(angle).translate(xy1[0], xy1[1])

    p1 = PathPatch(trans.transform_path(text_path), **kwargs)
    ax.add_patch(p1)
    art3d.pathpatch_2d_to_3d(p1, z=z1, zdir=zdir) 
开发者ID:holzschu,项目名称:python3_ios,代码行数:26,代码来源:pathpatch3d.py

示例9: plot_polygon_patch

# 需要导入模块: from matplotlib import patches [as 别名]
# 或者: from matplotlib.patches import PathPatch [as 别名]
def plot_polygon_patch(poly, color):
    """Plots a polygon as a patch."""
    # Outer clockwise path.
    coords = poly.GetGeometryRef(0).GetPoints()
    coords = order_coords(coords, True)
    codes = make_codes(len(coords))
    for i in range(1, poly.GetGeometryCount()):

        # Inner counter-clockwise paths.
        coords2 = poly.GetGeometryRef(i).GetPoints()
        coords2 = order_coords(coords2, False)
        codes2 = make_codes(len(coords2))

        # Concatenate the paths.
        coords = np.concatenate((coords, coords2))
        codes = np.concatenate((codes, codes2))

    # Add the patch to the plot
    path = Path(coords, codes)
    patch = patches.PathPatch(path, facecolor=color)
    plt.axes().add_patch(patch)

# Loop through all of the features in the countries layer and create
# patches for the polygons. 
开发者ID:cgarrard,项目名称:osgeopy-code,代码行数:26,代码来源:listing13_4.py

示例10: draw_edges

# 需要导入模块: from matplotlib import patches [as 别名]
# 或者: from matplotlib.patches import PathPatch [as 别名]
def draw_edges(self):
        """
        Renders edges to the figure.
        """
        for i, (start, end) in enumerate(self.graph.edges()):
            start_theta = node_theta(self.nodes, start)
            end_theta = node_theta(self.nodes, end)
            verts = [
                get_cartesian(self.plot_radius, start_theta),
                (0, 0),
                get_cartesian(self.plot_radius, end_theta),
            ]
            color = self.edge_colors[i]
            codes = [Path.MOVETO, Path.CURVE3, Path.CURVE3]
            lw = self.edge_widths[i]
            path = Path(verts, codes)
            patch = patches.PathPatch(
                path, lw=lw, edgecolor=color, zorder=1, **self.edgeprops
            )
            self.ax.add_patch(patch) 
开发者ID:ericmjl,项目名称:nxviz,代码行数:22,代码来源:plots.py

示例11: DrawClipBorders

# 需要导入模块: from matplotlib import patches [as 别名]
# 或者: from matplotlib.patches import PathPatch [as 别名]
def DrawClipBorders(clipborders):

        # 绘制裁切区域边界并返回
        path = clipborders[0].path
        linewidth = clipborders[0].linewidth
        linecolor = clipborders[0].linecolor
        if path is not None:
            patch = patches.PathPatch(path, linewidth=linewidth, facecolor='none', edgecolor=linecolor)
            plt.gca().add_patch(patch)
        else:
            patch = None
        return patch 
开发者ID:flashlxy,项目名称:PyMICAPS,代码行数:14,代码来源:Map.py

示例12: DrawBorders

# 需要导入模块: from matplotlib import patches [as 别名]
# 或者: from matplotlib.patches import PathPatch [as 别名]
def DrawBorders(m, products):
        """
        画县市边界
        :param m: 画布对象(plt或投影后的plt)
        :param products: 产品参数
        :return: 
        """
        try:
            for area in products.map.borders:
                if not area.draw:
                    continue
                if area.filetype == 'SHP':  # shp文件
                    if m is plt:
                        # Map.DrawShapeFile(area)
                        Map.readshapefile(area.file.replace('.shp', ''),
                                          os.path.basename(area.file),
                                          color=area.linecolor,
                                          linewidth=area.linewidth)
                    else:
                        m.readshapefile(area.file.replace('.shp', ''),
                                        os.path.basename(area.file),
                                        color=area.linecolor)
                else:  # 文本文件 , 画之前 路径中的点已经被投影了
                    if area.path is None:
                        continue
                    if area.polygon == 'ON':
                        area_patch = patches.PathPatch(area.path,
                                                       linewidth=area.linewidth,
                                                       linestyle='solid',
                                                       facecolor='none',
                                                       edgecolor=area.linecolor)
                        plt.gca().add_patch(area_patch)
                    else:
                        x, y = list(zip(*area.path.vertices))
                        m.plot(x, y, 'k-', linewidth=area.linewidth, color=area.linecolor)
        except Exception as err:
            print(u'【{0}】{1}-{2}'.format(products.xmlfile, err, datetime.now())) 
开发者ID:flashlxy,项目名称:PyMICAPS,代码行数:39,代码来源:Map.py

示例13: shp2clip

# 需要导入模块: from matplotlib import patches [as 别名]
# 或者: from matplotlib.patches import PathPatch [as 别名]
def shp2clip(originfig, ax, shpfile, region):
    path = getPathFromShp(shpfile=shpfile, region=region)
    patch = None
    if path:
        patch = PathPatch(path, transform=ax.transData, facecolor='none', edgecolor='black')
        for contour in originfig.collections:
            contour.set_clip_path(patch)
    return path, patch 
开发者ID:flashlxy,项目名称:PyMICAPS,代码行数:10,代码来源:maskout.py

示例14: GetPatches

# 需要导入模块: from matplotlib import patches [as 别名]
# 或者: from matplotlib.patches import PathPatch [as 别名]
def GetPatches(self, paths):
        ps = []
        for path in paths:
            from matplotlib import patches
            ps.append(patches.PathPatch(path, linewidth=1, facecolor='none', edgecolor='k'))
        return ps 
开发者ID:flashlxy,项目名称:PyMICAPS,代码行数:8,代码来源:Micaps11Data.py

示例15: setPlot

# 需要导入模块: from matplotlib import patches [as 别名]
# 或者: from matplotlib.patches import PathPatch [as 别名]
def setPlot(self):
        #绘制跑道
        verts = [
            (self.rX[0] - self.xOffset, self.rY[0] + self.yOffset),
            (self.rX[1] - self.xOffset, self.rY[1] + self.yOffset),
            (self.rX[1] + self.xOffset, self.rY[1] - self.yOffset),
            (self.rX[0] + self.xOffset, self.rY[0] - self.yOffset),
            (self.rX[0] - self.xOffset, self.rY[0] + self.yOffset)
        ]
        codes = [
            Path.MOVETO,
            Path.LINETO,
            Path.LINETO,
            Path.LINETO,
            Path.CLOSEPOLY,
        ]

        path = Path(verts, codes)
        patch = patches.PathPatch(path, facecolor='white', alpha = 0.3)
        self.plotLayer.add_patch(patch)

        #绘制边界
        self.plotLayer.plot([self.rX[0] - self.xOffset, self.rX[1] - self.xOffset], [self.rY[0] + self.yOffset, self.rY[1] + self.yOffset], 'w')
        self.plotLayer.plot([self.rX[0] + self.xOffset, self.rX[1] + self.xOffset], [self.rY[0] - self.yOffset, self.rY[1] - self.yOffset], 'w')

        #绘制车道
        for i in xrange(1,self.lanes+1):
             self.plotLayer.plot() 
开发者ID:xiongbeer,项目名称:Eins,代码行数:30,代码来源:testplot.py


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