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


Python patches.Circle方法代码示例

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


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

示例1: test_lines_dists

# 需要导入模块: from matplotlib import patches [as 别名]
# 或者: from matplotlib.patches import Circle [as 别名]
def test_lines_dists():
    import pylab
    ax = pylab.gca()

    xs, ys = (0,30), (20,150)
    pylab.plot(xs, ys)
    points = list(zip(xs, ys))
    p0, p1 = points

    xs, ys = (0,0,20,30), (100,150,30,200)
    pylab.scatter(xs, ys)

    dist = line2d_seg_dist(p0, p1, (xs[0], ys[0]))
    dist = line2d_seg_dist(p0, p1, np.array((xs, ys)))
    for x, y, d in zip(xs, ys, dist):
        c = Circle((x, y), d, fill=0)
        ax.add_patch(c)

    pylab.xlim(-200, 200)
    pylab.ylim(-200, 200)
    pylab.show() 
开发者ID:Sterncat,项目名称:opticspy,代码行数:23,代码来源:proj3d.py

示例2: construct_ball_trajectory

# 需要导入模块: from matplotlib import patches [as 别名]
# 或者: from matplotlib.patches import Circle [as 别名]
def construct_ball_trajectory(var, r=1., cmap='Blues', start_color=0.4, shape='c'):
    # https://matplotlib.org/examples/color/colormaps_reference.html
    patches = []
    for pos in var:
        if shape == 'c':
            patches.append(mpatches.Circle(pos, r))
        elif shape == 'r':
            patches.append(mpatches.RegularPolygon(pos, 4, r))
        elif shape == 's':
            patches.append(mpatches.RegularPolygon(pos, 6, r))

    colors = np.linspace(start_color, .9, len(patches))
    collection = PatchCollection(patches, cmap=cm.get_cmap(cmap), alpha=1.)
    collection.set_array(np.array(colors))
    collection.set_clim(0, 1)
    return collection 
开发者ID:simonkamronn,项目名称:kvae,代码行数:18,代码来源:plotting.py

示例3: test_PointSource

# 需要导入模块: from matplotlib import patches [as 别名]
# 或者: from matplotlib.patches import Circle [as 别名]
def test_PointSource():
    electrode = PointSource(0, 1, 2)
    npt.assert_almost_equal(electrode.x, 0)
    npt.assert_almost_equal(electrode.y, 1)
    npt.assert_almost_equal(electrode.z, 2)
    npt.assert_almost_equal(electrode.electric_potential(0, 1, 2, 1, 1), 1)
    npt.assert_almost_equal(electrode.electric_potential(0, 0, 0, 1, 1), 0.035,
                            decimal=3)
    # Slots:
    npt.assert_equal(hasattr(electrode, '__slots__'), True)
    npt.assert_equal(hasattr(electrode, '__dict__'), False)
    # Plots:
    ax = electrode.plot()
    npt.assert_equal(len(ax.texts), 0)
    npt.assert_equal(len(ax.patches), 1)
    npt.assert_equal(isinstance(ax.patches[0], Circle), True) 
开发者ID:pulse2percept,项目名称:pulse2percept,代码行数:18,代码来源:test_electrodes.py

示例4: test_PhotovoltaicPixel

# 需要导入模块: from matplotlib import patches [as 别名]
# 或者: from matplotlib.patches import Circle [as 别名]
def test_PhotovoltaicPixel():
    electrode = PhotovoltaicPixel(0, 1, 2, 3, 4)
    npt.assert_almost_equal(electrode.x, 0)
    npt.assert_almost_equal(electrode.y, 1)
    npt.assert_almost_equal(electrode.z, 2)
    npt.assert_almost_equal(electrode.r, 3)
    npt.assert_almost_equal(electrode.a, 4)
    # Slots:
    npt.assert_equal(hasattr(electrode, '__slots__'), True)
    npt.assert_equal(hasattr(electrode, '__dict__'), False)
    # Plots:
    ax = electrode.plot()
    npt.assert_equal(len(ax.texts), 0)
    npt.assert_equal(len(ax.patches), 2)
    npt.assert_equal(isinstance(ax.patches[0], RegularPolygon), True)
    npt.assert_equal(isinstance(ax.patches[1], Circle), True)
    PhotovoltaicPixel(0, 1, 2, 3, 4) 
开发者ID:pulse2percept,项目名称:pulse2percept,代码行数:19,代码来源:test_prima.py

示例5: _draw_nucleotide_body

# 需要导入模块: from matplotlib import patches [as 别名]
# 或者: from matplotlib.patches import Circle [as 别名]
def _draw_nucleotide_body(nucleotide, center, subplot: plt_axes.Subplot,
                          radius=10.0):
    nucleotide_color, nucleotide_base_class = _get_nucleotide_color(nucleotide)
    nucleotide_name = nucleotide.name
    if len(nucleotide_name) > 10:
        nucleotide_name = nucleotide_name.replace("_", "_\n")

    nucleotide_body = patches.Circle(
        center, radius=radius, color=nucleotide_color)
    text_object = subplot.text(
        center[0], center[1], nucleotide_name, va="center", ha="center")
    text_object.draw(subplot.figure.canvas.renderer)
    subplot.add_patch(nucleotide_body)
    nucleotide_body.add_callback(
        partial(_nucleotide_name_callback, text_object=text_object))
    nucleotide_body.set_label(":".join([nucleotide_base_class.__name__,
                                        nucleotide.name]))
    nucleotide_body.set_picker(True)
    return nucleotide_body 
开发者ID:audi,项目名称:nucleus7,代码行数:21,代码来源:vis_utils.py

示例6: test_lines_dists

# 需要导入模块: from matplotlib import patches [as 别名]
# 或者: from matplotlib.patches import Circle [as 别名]
def test_lines_dists():
    import pylab
    ax = pylab.gca()

    xs, ys = (0,30), (20,150)
    pylab.plot(xs, ys)
    points = zip(xs, ys)
    p0, p1 = points

    xs, ys = (0,0,20,30), (100,150,30,200)
    pylab.scatter(xs, ys)

    dist = line2d_seg_dist(p0, p1, (xs[0], ys[0]))
    dist = line2d_seg_dist(p0, p1, np.array((xs, ys)))
    for x, y, d in zip(xs, ys, dist):
        c = Circle((x, y), d, fill=0)
        ax.add_patch(c)

    pylab.xlim(-200, 200)
    pylab.ylim(-200, 200)
    pylab.show() 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:23,代码来源:proj3d.py

示例7: test_axisbelow

# 需要导入模块: from matplotlib import patches [as 别名]
# 或者: from matplotlib.patches import Circle [as 别名]
def test_axisbelow():
    # Test 'line' setting added in 6287.
    # Show only grids, not frame or ticks, to make this test
    # independent of future change to drawing order of those elements.
    fig, axs = plt.subplots(ncols=3, sharex=True, sharey=True)
    settings = (False, 'line', True)

    for ax, setting in zip(axs, settings):
        ax.plot((0, 10), (0, 10), lw=10, color='m')
        circ = mpatches.Circle((3, 3), color='r')
        ax.add_patch(circ)
        ax.grid(color='c', linestyle='-', linewidth=3)
        ax.tick_params(top=False, bottom=False,
                       left=False, right=False)
        for spine in ax.spines.values():
            spine.set_visible(False)
        ax.set_axisbelow(setting) 
开发者ID:holzschu,项目名称:python3_ios,代码行数:19,代码来源:test_axes.py

示例8: __init__

# 需要导入模块: from matplotlib import patches [as 别名]
# 或者: from matplotlib.patches import Circle [as 别名]
def __init__(self, map, points,radius):
        self.points = points
        self.radius = radius #radius in km

        #Points on the map projection
        self.points_to_map  = [map.to_pixels(p[0], p[1]) for p in self.points]

        # Radius in the map projection
        b = self.__geodesic_point_buffer(points[0][0], points[0][1], self.radius)
        bonmap = map.to_pixels(b[0])
        ponmap = map.to_pixels(points[0][0],points[0][1])
        distance = math.sqrt(math.pow((bonmap[0]-ponmap[0]),2)+math.pow((bonmap[1]-ponmap[1]),2))
        self.radius_on_coordinates = distance

        # Region on the map projection
        self.regions_to_map = [Circle((region[0],region[1]),self.radius_on_coordinates) for region in self.points_to_map]

        # Color of the regions
        self.cmap = plt.cm.Accent
        self.colors_cells = self.cmap(np.linspace(0., 1., len(self.points)))[:, :3] 
开发者ID:acsicuib,项目名称:YAFS,代码行数:22,代码来源:coverage.py

示例9: create_qc

# 需要导入模块: from matplotlib import patches [as 别名]
# 或者: from matplotlib.patches import Circle [as 别名]
def create_qc(fname_in, fname_gt, fname_out):
    img, gt = Image(fname_in), Image(fname_gt)
    img.change_orientation('RPI')
    gt.change_orientation('RPI')
    coord_c2c3 = np.where(gt.data == 1)
    y_c2c3, z_c2c3 = coord_c2c3[1][0], coord_c2c3[2][0]
    sag_slice = img.data[0, :, :]
    del img, gt

    ax = plt.gca()
    ax.imshow(sag_slice, interpolation='nearest', cmap='gray', aspect='auto')
    circ = Circle((z_c2c3, y_c2c3), 2, facecolor='chartreuse')
    ax.add_patch(circ)
    ax.get_xaxis().set_visible(False)
    ax.get_yaxis().set_visible(False)
    plt.savefig(fname_out)
    plt.close() 
开发者ID:neuropoly,项目名称:spinalcordtoolbox,代码行数:19,代码来源:train.py

示例10: draw_bbox2d

# 需要导入模块: from matplotlib import patches [as 别名]
# 或者: from matplotlib.patches import Circle [as 别名]
def draw_bbox2d(objects, color='k', ax=None):

    limits = ax.axis()

    for obj in objects:
        x, _, z = obj.position
        l, _, w = obj.dimensions

        # Setup transform 
        t = transforms.Affine2D().rotate(obj.angle + math.pi/2)
        t = t.translate(x, z) + ax.transData

        # Draw 2D object bounding box
        rect = Rectangle((-w/2, -l/2), w, l, edgecolor=color, transform=t, fill=False)
        ax.add_patch(rect)

        # Draw dot indicating object center
        center = Circle((x, z), 0.25, facecolor='k')
        ax.add_patch(center)

    ax.axis(limits)
    return ax 
开发者ID:tom-roddick,项目名称:oft,代码行数:24,代码来源:bbox.py

示例11: plot_3d_ball_trajectory

# 需要导入模块: from matplotlib import patches [as 别名]
# 或者: from matplotlib.patches import Circle [as 别名]
def plot_3d_ball_trajectory(var, filename, r=0.05):
    var = np.asarray(var)

    # Normalize directions
    var -= var.min(axis=0)
    var /= var.max(axis=0)

    fig = plt.figure()
    ax = fig.add_subplot(111, projection='3d')
    for x, y, z in var:
        p = mpatches.Circle((x, y), r, ec="none")
        ax.add_patch(p)
        art3d.pathpatch_2d_to_3d(p, z=0, zdir="z")

        p = mpatches.Circle((x, z), r, ec="none")
        ax.add_patch(p)
        art3d.pathpatch_2d_to_3d(p, z=0, zdir="y")

        p = mpatches.Circle((y, z), r, ec="none")
        ax.add_patch(p)
        art3d.pathpatch_2d_to_3d(p, z=0, zdir="x")

        # ax.scatter(x, y, z, s=100)
    # ax.plot(var[:, 0], var[:, 1], zs=var[:, 2])

    ax.view_init(azim=45, elev=30)
    ax.set_xlim3d(-0.1, 1.1)
    ax.set_ylim3d(-0.1, 1.1)
    ax.set_zlim3d(-0.1, 1.1)
    plt.savefig(filename, format='png', bbox_inches='tight', dpi=80)
    plt.close(fig)
    # plt.show() 
开发者ID:simonkamronn,项目名称:kvae,代码行数:34,代码来源:plotting.py

示例12: showAnns

# 需要导入模块: from matplotlib import patches [as 别名]
# 或者: from matplotlib.patches import Circle [as 别名]
def showAnns(self, objects, imgId, range):
        """
        :param catNms: category names
        :param objects: objects to show
        :param imgId: img to show
        :param range: display range in the img
        :return:
        """
        img = self.loadImgs(imgId)[0]
        plt.imshow(img)
        plt.axis('off')

        ax = plt.gca()
        ax.set_autoscale_on(False)
        polygons = []
        color = []
        circles = []
        r = 5
        for obj in objects:
            c = (np.random.random((1, 3)) * 0.6 + 0.4).tolist()[0]
            poly = obj['poly']
            polygons.append(Polygon(poly))
            color.append(c)
            point = poly[0]
            circle = Circle((point[0], point[1]), r)
            circles.append(circle)
        p = PatchCollection(polygons, facecolors=color, linewidths=0, alpha=0.4)
        ax.add_collection(p)
        p = PatchCollection(polygons, facecolors='none', edgecolors=color, linewidths=2)
        ax.add_collection(p)
        p = PatchCollection(circles, facecolors='red')
        ax.add_collection(p) 
开发者ID:dingjiansw101,项目名称:AerialDetection,代码行数:34,代码来源:DOTA.py

示例13: test_DiskElectrode

# 需要导入模块: from matplotlib import patches [as 别名]
# 或者: from matplotlib.patches import Circle [as 别名]
def test_DiskElectrode():
    with pytest.raises(TypeError):
        DiskElectrode(0, 0, 0, [1, 2])
    with pytest.raises(TypeError):
        DiskElectrode(0, np.array([0, 1]), 0, 1)
    # Invalid radius:
    with pytest.raises(ValueError):
        DiskElectrode(0, 0, 0, -5)
    # Check params:
    electrode = DiskElectrode(0, 1, 2, 100)
    npt.assert_almost_equal(electrode.x, 0)
    npt.assert_almost_equal(electrode.y, 1)
    npt.assert_almost_equal(electrode.z, 2)
    # On the electrode surface (z=2, x^2+y^2<=100^2)
    npt.assert_almost_equal(electrode.electric_potential(0, 1, 2, 1), 1)
    npt.assert_almost_equal(electrode.electric_potential(30, -30, 2, 1), 1)
    npt.assert_almost_equal(electrode.electric_potential(0, 101, 2, 1), 1)
    npt.assert_almost_equal(electrode.electric_potential(0, -99, 2, 1), 1)
    npt.assert_almost_equal(electrode.electric_potential(100, 1, 2, 1), 1)
    npt.assert_almost_equal(electrode.electric_potential(-100, 1, 2, 1), 1)
    # Right off the surface (z=2, x^2+y^2>100^2)
    npt.assert_almost_equal(electrode.electric_potential(0, 102, 2, 1), 0.910,
                            decimal=3)
    npt.assert_almost_equal(electrode.electric_potential(0, -100, 2, 1), 0.910,
                            decimal=3)
    # Some distance away from the electrode (z>2):
    npt.assert_almost_equal(electrode.electric_potential(0, 1, 38, 1), 0.780,
                            decimal=3)
    # Slots:
    npt.assert_equal(hasattr(electrode, '__slots__'), True)
    npt.assert_equal(hasattr(electrode, '__dict__'), False)
    # Plots:
    ax = electrode.plot()
    npt.assert_equal(len(ax.texts), 0)
    npt.assert_equal(len(ax.patches), 1)
    npt.assert_equal(isinstance(ax.patches[0], Circle), True) 
开发者ID:pulse2percept,项目名称:pulse2percept,代码行数:38,代码来源:test_electrodes.py

示例14: __init__

# 需要导入模块: from matplotlib import patches [as 别名]
# 或者: from matplotlib.patches import Circle [as 别名]
def __init__(self, x, y, z, r, a):
        super(PhotovoltaicPixel, self).__init__(x, y, z, a)
        if isinstance(r, (Sequence, np.ndarray)):
            raise TypeError("Radius of the active electrode must be a scalar.")
        if r <= 0:
            raise ValueError("Radius of the active electrode must be > 0, not "
                             "%f." % r)
        self.r = r
        # Plot two objects: hex honeycomb and circular active electrode
        self.plot_patch = [RegularPolygon, Circle]
        self.plot_kwargs = [{'radius': a, 'numVertices': 6, 'alpha': 0.2,
                             'orientation': np.radians(30), 'fc': 'k',
                             'ec': 'k'},
                            {'radius': r, 'linewidth': 0, 'color': 'k',
                             'alpha': 0.5}] 
开发者ID:pulse2percept,项目名称:pulse2percept,代码行数:17,代码来源:prima.py

示例15: __init__

# 需要导入模块: from matplotlib import patches [as 别名]
# 或者: from matplotlib.patches import Circle [as 别名]
def __init__(self, x, y, z):
        super(PointSource, self).__init__(x, y, z)
        self.plot_patch = Circle
        self.plot_kwargs = {'radius': 5, 'linewidth': 2,
                            'ec': (0.3, 0.3, 0.3, 1),
                            'fc': (0.8, 0.8, 0.8, 0.7)} 
开发者ID:pulse2percept,项目名称:pulse2percept,代码行数:8,代码来源:electrodes.py


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