當前位置: 首頁>>代碼示例>>Python>>正文


Python pyplot.Circle方法代碼示例

本文整理匯總了Python中matplotlib.pyplot.Circle方法的典型用法代碼示例。如果您正苦於以下問題:Python pyplot.Circle方法的具體用法?Python pyplot.Circle怎麽用?Python pyplot.Circle使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在matplotlib.pyplot的用法示例。


在下文中一共展示了pyplot.Circle方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_figure

# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import Circle [as 別名]
def test_figure(self):
        writer = SummaryWriter()

        figure, axes = plt.figure(), plt.gca()
        circle1 = plt.Circle((0.2, 0.5), 0.2, color='r')
        circle2 = plt.Circle((0.8, 0.5), 0.2, color='g')
        axes.add_patch(circle1)
        axes.add_patch(circle2)
        plt.axis('scaled')
        plt.tight_layout()

        writer.add_figure("add_figure/figure", figure, 0, close=False)
        assert plt.fignum_exists(figure.number) is True

        writer.add_figure("add_figure/figure", figure, 1)
        assert plt.fignum_exists(figure.number) is False

        writer.close() 
開發者ID:lanpa,項目名稱:tensorboardX,代碼行數:20,代碼來源:test_figure.py

示例2: _draw_topos_one_sub

# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import Circle [as 別名]
def _draw_topos_one_sub(self, fig, sub_id, buses_z, elements, bus_vect):
        fig, ax = fig
        res_sub = []
        # I plot the buses
        for bus_id, z_bus in enumerate(buses_z):
            bus_color = '#ff7f0e' if bus_id == 0 else '#1f77b4'
            bus_circ = plt.Circle((z_bus.real, z_bus.imag), self.bus_radius, color=bus_color, fill=True)
            ax.add_artist(bus_circ)

        # i connect every element to the proper bus with the proper color
        for el_nm, dict_el in elements.items():
            this_el_bus = bus_vect[dict_el["sub_pos"]] -1
            if this_el_bus >= 0:
                color = '#ff7f0e' if this_el_bus == 0 else '#1f77b4'
                ax.plot([buses_z[this_el_bus].real, dict_el["z"].real],
                        [ buses_z[this_el_bus].imag, dict_el["z"].imag],
                        color=color, alpha=self.alpha_obj)
        return [] 
開發者ID:rte-france,項目名稱:Grid2Op,代碼行數:20,代碼來源:PlotMatplotlib.py

示例3: plot_colored_circles

# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import Circle [as 別名]
def plot_colored_circles(ax, prng, nb_samples=15):
    """Plot circle patches.

    NB: draws a fixed amount of samples, rather than using the length of
    the color cycle, because different styles may have different numbers
    of colors.
    """
    for sty_dict, j in zip(plt.rcParams['axes.prop_cycle'], range(nb_samples)):
        ax.add_patch(plt.Circle(prng.normal(scale=3, size=2),
                                radius=1.0, color=sty_dict['color']))
    # Force the limits to be the same across the styles (because different
    # styles may have different numbers of available colors).
    ax.set_xlim([-4, 8])
    ax.set_ylim([-5, 6])
    ax.set_aspect('equal', adjustable='box')  # to plot circles as circles
    return ax 
開發者ID:holzschu,項目名稱:python3_ios,代碼行數:18,代碼來源:style_sheets_reference.py

示例4: plot

# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import Circle [as 別名]
def plot(self, axis=None, show=False):
        """
        Plot the coil location, using axis if given
    
        The area of the coil is used to set the radius
        """
        minor_radius = np.sqrt(self.area / np.pi)
        
        import matplotlib.pyplot as plt
        
        if axis is None:
            fig = plt.figure()
            axis = fig.add_subplot(111)
            
        circle = plt.Circle((self.R, self.Z), minor_radius, color='b')
        axis.add_artist(circle)
        return axis 
開發者ID:bendudson,項目名稱:freegs,代碼行數:19,代碼來源:coil.py

示例5: plot

# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import Circle [as 別名]
def plot(self, show_axes=False):
        import matplotlib.pyplot as plt

        ax = plt.gca()
        # change default range so that new disks will work
        ax.axis("equal")
        ax.set_xlim((-1.5, 1.5))
        ax.set_ylim((-1.5, 1.5))

        if not show_axes:
            ax.set_axis_off()

        disk1 = plt.Circle((0, 0), 1, color="k", fill=False)
        ax.add_artist(disk1)

        # The total area is used to gauge the disk radii. This is only meaningful for 2D
        # manifolds, not for the circle. What we do instead is choose the total_area
        # such that the sum of the disk radii equals pi.
        total_area = numpy.pi ** 3 / len(self.weights)
        plot_disks(plt, self.points, self.weights, total_area) 
開發者ID:nschloe,項目名稱:quadpy,代碼行數:22,代碼來源:_helpers.py

示例6: plot

# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import Circle [as 別名]
def plot(self, show_axes=False):
        import matplotlib.pyplot as plt

        ax = plt.gca()
        # change default range so that new disks will work
        plt.axis("equal")
        ax.set_xlim((-1.5, 1.5))
        ax.set_ylim((-1.5, 1.5))

        if not show_axes:
            ax.set_axis_off()

        disk1 = plt.Circle((0, 0), 1, color="k", fill=False)
        ax.add_artist(disk1)

        plot_disks(plt, self.points, self.weights, numpy.pi)
        return 
開發者ID:nschloe,項目名稱:quadpy,代碼行數:19,代碼來源:_helpers.py

示例7: __init__

# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import Circle [as 別名]
def __init__(self, pendulum_plant, refresh_period=(1.0/240),
                 name='PendulumDraw'):
        super(PendulumDraw, self).__init__(pendulum_plant,
                                           refresh_period, name)
        l = self.plant.l
        m = self.plant.m

        self.mass_r = 0.05*np.sqrt(m)  # distance to corner of bounding box

        self.center_x = 0
        self.center_y = 0

        # initialize the patches to draw the pendulum
        self.pole_line = plt.Line2D((self.center_x, 0), (self.center_y, l),
                                    lw=2, c='r')
        self.mass_circle = plt.Circle((0, l), self.mass_r, fc='y') 
開發者ID:mcgillmrl,項目名稱:kusanagi,代碼行數:18,代碼來源:pendulum.py

示例8: __init__

# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import Circle [as 別名]
def __init__(self,to_plot = True):
        self.state = np.array([0,0])        
        self.observation_shape = np.shape(self.get_state())[0]
        
        if to_plot:
            plt.ion()
            fig = plt.figure()
            ax1 = fig.add_subplot(111,aspect='equal')
            #ax1.axis('off')
            plt.xlim([-0.5,5.5])
            plt.ylim([-0.5,5.5])

            self.g1 = ax1.add_artist(plt.Circle((self.state[0],self.state[1]),0.1,color='red'))
            self.fig = fig
            self.ax1 = ax1
            self.fig.canvas.draw()
            self.fig.canvas.flush_events() 
開發者ID:tmoer,項目名稱:multimodal_varinf,代碼行數:19,代碼來源:chicken.py

示例9: _draw_maze_

# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import Circle [as 別名]
def _draw_maze_(maze_env, ax):
    """
    The function to draw maze environment
    Arguments:
        maze_env:   The maze environment configuration.
        ax:         The figure axis instance
    """
    # draw maze walls
    for wall in maze_env.walls:
        line = plt.Line2D((wall.a.x, wall.b.x), (wall.a.y, wall.b.y), lw=1.5)
        ax.add_line(line)

    # draw start point
    start_circle = plt.Circle((maze_env.agent.location.x, maze_env.agent.location.y), 
                                radius=2.5, facecolor=(0.6, 1.0, 0.6), edgecolor='w')
    ax.add_patch(start_circle)
    
    # draw exit point
    exit_circle = plt.Circle((maze_env.exit_point.x, maze_env.exit_point.y), 
                                radius=2.5, facecolor=(1.0, 0.2, 0.0), edgecolor='w')
    ax.add_patch(exit_circle) 
開發者ID:PacktPublishing,項目名稱:Hands-on-Neuroevolution-with-Python,代碼行數:23,代碼來源:visualize.py

示例10: main

# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import Circle [as 別名]
def main(show_animation):
    cp = demo_cp
    rx, ry, ryaw, rk = calcTrajectory(cp, 100)

    t = 0.8
    x_target, y_target = bezier(t, cp)
    derivatives_cp = bezierDerivativesControlPoints(cp, 2)
    point = bezier(t, cp)
    dt = bezier(t, derivatives_cp[1])
    ddt = bezier(t, derivatives_cp[2])
    cu = curvature(dt[0], dt[1], ddt[0], ddt[1])
    # Normalize derivative
    dt /= np.linalg.norm(dt, 2)
    tangent = np.array([point, point + dt])
    normal = np.array([point, point + [- dt[1], dt[0]]])
    # Radius of curvature
    r = 1 / cu

    curvature_center = point + np.array([- dt[1], dt[0]]) * r
    circle = plt.Circle(tuple(curvature_center), r, color=(0, 0.8, 0.8), fill=False, linewidth=1)


    if show_animation:  # pragma: no cover
        fig, ax = plt.subplots()
        ax.plot(rx, ry, label="Bezier Path")
        ax.plot(cp.T[0], cp.T[1], '--o', label="Control Points")
        ax.plot(x_target, y_target, '--o', label="Target Point")
        ax.plot(tangent[:, 0], tangent[:, 1], label="Tangent")
        ax.plot(normal[:, 0], normal[:, 1], label="Normal")
        ax.add_artist(circle)
        ax.legend()
        ax.axis("equal")
        ax.grid(True)
        plt.show() 
開發者ID:sergionr2,項目名稱:RacingRobot,代碼行數:36,代碼來源:bezier_curve.py

示例11: legend_demo

# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import Circle [as 別名]
def legend_demo(ax):
    x = np.linspace(0, 1, 30)
    ax.plot(x, np.sin(2*np.pi*x), '-s', label='line')
    c = plt.Circle((0.25, 0), radius=0.1, label='patch')
    ax.add_patch(c)
    ax.grid()
    ax.legend()
    ax.set_title('legend') 
開發者ID:tonysyu,項目名稱:matplotlib-style-gallery,代碼行數:10,代碼來源:artist-demo.py

示例12: circle_and_text_demo

# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import Circle [as 別名]
def circle_and_text_demo(ax):

    # Circles with colors from default color cycle
    for i, color in enumerate(plt.rcParams['axes.color_cycle']):
        xy = np.random.normal(size=2)
        ax.add_patch(plt.Circle(xy, radius=0.3, color=color))
    ax.axis('equal')
    ax.margins(0)

    # Text label centered on the axes.
    ax.text(0.5, 0.5, 'hello world', ha='center', va='center',
            transform=ax.transAxes)
    ax.set_xlabel('x-label')
    ax.set_ylabel('y-label')
    ax.set_title('title') 
開發者ID:tonysyu,項目名稱:matplotlib-style-gallery,代碼行數:17,代碼來源:artist-demo.py

示例13: __init__

# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import Circle [as 別名]
def __init__(self,drawing,**kwargs):
    for k in ['coord','text','label']:
      setattr(self,k,kwargs[k])
    self.txt = plt.text(self.coord[0]+40,self.coord[1]+20,self.text,size=16)
    self.dot = plt.Circle(self.coord,20)
    drawing.ax.add_artist(self.dot)
    low,high = drawing.crange
    self.amp = high-low
    self.low = low 
開發者ID:LaboratoireMecaniqueLille,項目名稱:crappy,代碼行數:11,代碼來源:drawing.py

示例14: my_plot

# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import Circle [as 別名]
def my_plot(fig, figures_i):
    ax = fig.add_subplot(111, projection='3d')

    X_i = X[figures_i, :, :]
    U_i = U[figures_i, :, :]
    K = X_i.shape[1]

    ax.set_xlabel('X, east')
    ax.set_ylabel('Y, north')
    ax.set_zlabel('Z, up')

    for k in range(K):
        rx, ry, rz = X_i[1:4, k]
        qw, qx, qy, qz = X_i[7:11, k]

        CBI = np.array([
            [1 - 2 * (qy ** 2 + qz ** 2), 2 * (qx * qy + qw * qz), 2 * (qx * qz - qw * qy)],
            [2 * (qx * qy - qw * qz), 1 - 2 * (qx ** 2 + qz ** 2), 2 * (qy * qz + qw * qx)],
            [2 * (qx * qz + qw * qy), 2 * (qy * qz - qw * qx), 1 - 2 * (qx ** 2 + qy ** 2)]
        ])

        dx, dy, dz = np.dot(np.transpose(CBI), np.array([0., 0., 1.]))
        Fx, Fy, Fz = np.dot(np.transpose(CBI), U_i[:, k])

        # attitude vector
        ax.quiver(rx, ry, rz, dx, dy, dz, length=attitude_scale, arrow_length_ratio=0.0, color='blue')

        # thrust vector
        ax.quiver(rx, ry, rz, -Fx, -Fy, -Fz, length=thrust_scale, arrow_length_ratio=0.0, color='red')

    scale = X_i[3, 0]
    ax.auto_scale_xyz([-scale / 2, scale / 2], [-scale / 2, scale / 2], [0, scale])

    pad = plt.Circle((0, 0), 20, color='lightgray')
    ax.add_patch(pad)
    art3d.pathpatch_2d_to_3d(pad)

    ax.set_title("Iteration " + str(figures_i))
    ax.plot(X_i[1, :], X_i[2, :], X_i[3, :], color='lightgrey')
    ax.set_aspect('equal') 
開發者ID:EmbersArc,項目名稱:SCvx,代碼行數:42,代碼來源:rocket_landing_3d_plot.py

示例15: height

# 需要導入模塊: from matplotlib import pyplot [as 別名]
# 或者: from matplotlib.pyplot import Circle [as 別名]
def height(self):
        shape = self.brush.style[1]
        if isinstance(self.obj, plt.Circle):
            return self.obj.radius * 2
        elif isinstance(self.obj, plt.Rectangle):
            return self.obj.get_height()
        elif isinstance(self.obj, patches.FancyBboxPatch):
            return self.obj.get_height() + 2*self.obj.get_boxstyle().pad
        elif isinstance(self.obj, (plt.Polygon, patches.PathPatch)):
            y = self.path[:,1]
            return y.max() - y.min()
        else:
            raise 
開發者ID:GiggleLiu,項目名稱:viznet,代碼行數:15,代碼來源:edgenode.py


注:本文中的matplotlib.pyplot.Circle方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。