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


Python patches.Arc方法代碼示例

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


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

示例1: get_angle_plot

# 需要導入模塊: from matplotlib import patches [as 別名]
# 或者: from matplotlib.patches import Arc [as 別名]
def get_angle_plot(line1, line2, radius=1, color=None, origin=(0, 0),
                   len_x_axis=1, len_y_axis=1):

    l1xy = line1.get_xydata()
    # Angle between line1 and x-axis
    l1_xs = l1xy[:, 0]
    l1_ys = l1xy[:, 1]
    angle1 = np.degrees(np.arctan2(np.diff(l1_ys), np.diff(l1_xs)))

    l2xy = line2.get_xydata()
    # Angle between line2 and x-axis
    l2_xs = l2xy[:, 0]
    l2_ys = l2xy[:, 1]
    angle2 = np.degrees(np.arctan2(np.diff(l2_ys), np.diff(l2_xs)))

    theta1 = min(angle1, angle2)
    theta2 = max(angle1, angle2)

    if color is None:
        color = line1.get_color()  # Uses the color of line 1 if color parameter is not passed.
    return Arc(origin, len_x_axis * radius, len_y_axis * radius, 0, theta1, theta2, color=color) 
開發者ID:OpenMDAO,項目名稱:dymos,代碼行數:23,代碼來源:ssto_fbd.py

示例2: curved_view

# 需要導入模塊: from matplotlib import patches [as 別名]
# 或者: from matplotlib.patches import Arc [as 別名]
def curved_view(sheet, radius_cutoff=1e3):

    center_data = get_arc_data(sheet)
    fig, ax = sheet_view(sheet, **{"edge": {"visible": False}})

    curves = []
    for idx, edge in center_data.iterrows():
        if edge["radius"] > radius_cutoff:
            st = sheet.edge_df.loc[idx, ["srce", "trgt"]]
            xy = sheet.vert_df.loc[st, sheet.coords]
            patch = PathPatch(Path(xy))
        else:
            patch = Arc(
                edge[["x", "y"]],
                2 * edge["radius"],
                2 * edge["radius"],
                theta1=edge["theta1"] * 180 / np.pi,
                theta2=edge["theta2"] * 180 / np.pi,
            )
        curves.append(patch)
    ax.add_collection(PatchCollection(curves, False, **{"facecolors": "none"}))
    ax.autoscale()
    return fig, ax 
開發者ID:DamCB,項目名稱:tyssue,代碼行數:25,代碼來源:plt_draw.py

示例3: test_patch_str

# 需要導入模塊: from matplotlib import patches [as 別名]
# 或者: from matplotlib.patches import Arc [as 別名]
def test_patch_str():
    """
    Check that patches have nice and working `str` representation.

    Note that the logic is that `__str__` is defined such that:
    str(eval(str(p))) == str(p)
    """
    p = mpatches.Circle(xy=(1, 2), radius=3)
    assert str(p) == 'Circle(xy=(1, 2), radius=3)'

    p = mpatches.Ellipse(xy=(1, 2), width=3, height=4, angle=5)
    assert str(p) == 'Ellipse(xy=(1, 2), width=3, height=4, angle=5)'

    p = mpatches.Rectangle(xy=(1, 2), width=3, height=4, angle=5)
    assert str(p) == 'Rectangle(xy=(1, 2), width=3, height=4, angle=5)'

    p = mpatches.Wedge(center=(1, 2), r=3, theta1=4, theta2=5, width=6)
    assert str(p) == 'Wedge(center=(1, 2), r=3, theta1=4, theta2=5, width=6)'

    p = mpatches.Arc(xy=(1, 2), width=3, height=4, angle=5, theta1=6, theta2=7)
    expected = 'Arc(xy=(1, 2), width=3, height=4, angle=5, theta1=6, theta2=7)'
    assert str(p) == expected 
開發者ID:alvarobartt,項目名稱:twitter-stock-recommendation,代碼行數:24,代碼來源:test_patches.py

示例4: plot_contour

# 需要導入模塊: from matplotlib import patches [as 別名]
# 或者: from matplotlib.patches import Arc [as 別名]
def plot_contour(self, w=0.0):
    """
      Plot contour with poles of Green's function in the self-energy 
      SelfEnergy(w) = G(w+w')W(w')
      with respect to w' = Re(w')+Im(w')
      Poles of G(w+w') are located: w+w'-(E_n-Fermi)+i*eps sign(E_n-Fermi)==0 ==> 
      w'= (E_n-Fermi) - w -i eps sign(E_n-Fermi)
    """
    try :
      import matplotlib.pyplot as plt
      from matplotlib.patches import Arc, Arrow 
    except:
      print('no matplotlib?')
      return

    fig,ax = plt.subplots()
    fe = self.fermi_energy
    ee = self.mo_energy
    iee = 0.5-np.array(ee>fe)
    eew = ee-fe-w
    ax.plot(eew, iee, 'r.', ms=10.0)
    pp = list()
    pp.append(Arc((0,0),4,4,angle=0, linewidth=2, theta1=0, theta2=90, zorder=2, color='b'))
    pp.append(Arc((0,0),4,4,angle=0, linewidth=2, theta1=180, theta2=270, zorder=2, color='b'))
    pp.append(Arrow(0,2,0,-4,width=0.2, color='b', hatch='o'))
    pp.append(Arrow(-2,0,4,0,width=0.2, color='b', hatch='o'))
    for p in pp: ax.add_patch(p)
    ax.set_aspect('equal')
    ax.grid(True, which='both')
    ax.axhline(y=0, color='k')
    ax.axvline(x=0, color='k')
    plt.ylim(-3.0,3.0)
    plt.show() 
開發者ID:pyscf,項目名稱:pyscf,代碼行數:35,代碼來源:mf.py

示例5: test_arc_ellipse

# 需要導入模塊: from matplotlib import patches [as 別名]
# 或者: from matplotlib.patches import Arc [as 別名]
def test_arc_ellipse():
    from matplotlib import patches
    xcenter, ycenter = 0.38, 0.52
    width, height = 1e-1, 3e-1
    angle = -30

    theta = np.arange(0.0, 360.0, 1.0)*np.pi/180.0
    x = width/2. * np.cos(theta)
    y = height/2. * np.sin(theta)

    rtheta = angle*np.pi/180.
    R = np.array([
        [np.cos(rtheta),  -np.sin(rtheta)],
        [np.sin(rtheta), np.cos(rtheta)],
        ])

    x, y = np.dot(R, np.array([x, y]))
    x += xcenter
    y += ycenter

    fig = plt.figure()
    ax = fig.add_subplot(211, aspect='auto')
    ax.fill(x, y, alpha=0.2, facecolor='yellow', edgecolor='yellow', linewidth=1, zorder=1)

    e1 = patches.Arc((xcenter, ycenter), width, height,
                     angle=angle, linewidth=2, fill=False, zorder=2)

    ax.add_patch(e1)

    ax = fig.add_subplot(212, aspect='equal')
    ax.fill(x, y, alpha=0.2, facecolor='green', edgecolor='green', zorder=1)
    e2 = patches.Arc((xcenter, ycenter), width, height,
                     angle=angle, linewidth=2, fill=False, zorder=2)

    ax.add_patch(e2) 
開發者ID:miloharper,項目名稱:neural-network-animation,代碼行數:37,代碼來源:test_axes.py

示例6: plot_arcs

# 需要導入模塊: from matplotlib import patches [as 別名]
# 或者: from matplotlib.patches import Arc [as 別名]
def plot_arcs(self, ax, interval):

        width = (interval.end - interval.begin)
        if self.properties['compact_arcs_level'] == '1':
            half_height = np.sqrt(width)
        elif self.properties['compact_arcs_level'] == '2':
            half_height = 1000
        else:
            half_height = width
        center = interval.begin + width / 2
        if half_height > self.max_height:
            self.max_height = half_height
        # I think this was an error...
        # ax.plot([center], [diameter])
        if self.colormap:
            # translate score field
            # into a color
            rgb = self.colormap.to_rgba(interval.data[4])
        else:
            rgb = self.properties['color']
        ax.add_patch(Arc((center, 0), width,
                         2 * half_height, 0, 0, 180, color=rgb,
                         linewidth=self.line_width,
                         ls=self.properties['line_style'])) 
開發者ID:deeptools,項目名稱:pyGenomeTracks,代碼行數:26,代碼來源:LinksTrack.py

示例7: test_arc_angles

# 需要導入模塊: from matplotlib import patches [as 別名]
# 或者: from matplotlib.patches import Arc [as 別名]
def test_arc_angles():
    from matplotlib import patches
    # Ellipse parameters
    w = 2
    h = 1
    centre = (0.2, 0.5)
    scale = 2

    fig, axs = plt.subplots(3, 3)
    for i, ax in enumerate(axs.flat):
        theta2 = i * 360 / 9
        theta1 = theta2 - 45

        ax.add_patch(patches.Ellipse(centre, w, h, alpha=0.3))
        ax.add_patch(patches.Arc(centre, w, h, theta1=theta1, theta2=theta2))
        # Straight lines intersecting start and end of arc
        ax.plot([scale * np.cos(np.deg2rad(theta1)) + centre[0],
                 centre[0],
                 scale * np.cos(np.deg2rad(theta2)) + centre[0]],
                [scale * np.sin(np.deg2rad(theta1)) + centre[1],
                 centre[1],
                 scale * np.sin(np.deg2rad(theta2)) + centre[1]])

        ax.set_xlim(-scale, scale)
        ax.set_ylim(-scale, scale)

        # This looks the same, but it triggers a different code path when it
        # gets large enough.
        w *= 10
        h *= 10
        centre = (centre[0] * 10, centre[1] * 10)
        scale *= 10 
開發者ID:holzschu,項目名稱:python3_ios,代碼行數:34,代碼來源:test_axes.py

示例8: test_arc_ellipse

# 需要導入模塊: from matplotlib import patches [as 別名]
# 或者: from matplotlib.patches import Arc [as 別名]
def test_arc_ellipse():
    from matplotlib import patches
    xcenter, ycenter = 0.38, 0.52
    width, height = 1e-1, 3e-1
    angle = -30

    theta = np.deg2rad(np.arange(360))
    x = width / 2. * np.cos(theta)
    y = height / 2. * np.sin(theta)

    rtheta = np.deg2rad(angle)
    R = np.array([
        [np.cos(rtheta), -np.sin(rtheta)],
        [np.sin(rtheta), np.cos(rtheta)]])

    x, y = np.dot(R, np.array([x, y]))
    x += xcenter
    y += ycenter

    fig = plt.figure()
    ax = fig.add_subplot(211, aspect='auto')
    ax.fill(x, y, alpha=0.2, facecolor='yellow', edgecolor='yellow',
            linewidth=1, zorder=1)

    e1 = patches.Arc((xcenter, ycenter), width, height,
                     angle=angle, linewidth=2, fill=False, zorder=2)

    ax.add_patch(e1)

    ax = fig.add_subplot(212, aspect='equal')
    ax.fill(x, y, alpha=0.2, facecolor='green', edgecolor='green', zorder=1)
    e2 = patches.Arc((xcenter, ycenter), width, height,
                     angle=angle, linewidth=2, fill=False, zorder=2)

    ax.add_patch(e2) 
開發者ID:holzschu,項目名稱:python3_ios,代碼行數:37,代碼來源:test_axes.py

示例9: _measure

# 需要導入模塊: from matplotlib import patches [as 別名]
# 或者: from matplotlib.patches import Arc [as 別名]
def _measure(self, qxy, cxy, cid, fc=None, ec=None, gt=None, sc=None):
        qx, qy = qxy
        cx, cy = cxy

        # draw gate box
        self._gate(qxy, fc=fc, ec=ec, gt=gt, sc=sc)

        # add measure symbol
        arc = patches.Arc(xy=(qx, qy - 0.15 * HIG), width=WID * 0.7,
                          height=HIG * 0.7, theta1=0, theta2=180, fill=False,
                          ec=self._style.not_gate_lc, linewidth=2, zorder=PORDER_GATE)
        self.ax.add_patch(arc)
        self.ax.plot([qx, qx + 0.35 * WID], [qy - 0.15 * HIG, qy + 0.20 * HIG],
                     color=self._style.not_gate_lc, linewidth=2, zorder=PORDER_GATE)
        # arrow
        self._line(qxy, [cx, cy + 0.35 * WID], lc=self._style.cc, ls=self._style.cline)
        arrowhead = patches.Polygon(((cx - 0.20 * WID, cy + 0.35 * WID),
                                     (cx + 0.20 * WID, cy + 0.35 * WID),
                                     (cx, cy)), fc=self._style.cc, ec=None)
        self.ax.add_artist(arrowhead)
        # target
        if self.cregbundle:
            self.ax.text(cx + .25, cy + .1, str(cid), ha='left', va='bottom',
                         fontsize=0.8 * self._style.fs, color=self._style.tc,
                         clip_on=True, zorder=PORDER_TEXT) 
開發者ID:Qiskit,項目名稱:qiskit-terra,代碼行數:27,代碼來源:matplotlib.py

示例10: draw_arc

# 需要導入模塊: from matplotlib import patches [as 別名]
# 或者: from matplotlib.patches import Arc [as 別名]
def draw_arc(self, center: Vector, width: float, height: float, angle: Radians,
                 draw_angles: Optional[Tuple[Radians, Radians]], properties: Properties):
        if min(width, height) < 1e-5:
            return  # matplotlib crashes if the arc has almost 0 size

        if draw_angles is None:
            start_degrees, end_degrees = 0, 360
        else:
            # draw angles are relative to `angle`. The arc is drawn anticlockwise from start to end.
            # draw_angles are *NOT* in the global coordinate system, but instead are angles inside the
            # local coordinate system defined by the major and minor axes of the ellipse
            # (where the ellipse looks like a circle)
            ratio = height / width
            start, end = param_to_angle(ratio, draw_angles[0]), param_to_angle(ratio, draw_angles[1])
            start_degrees, end_degrees = degrees(start), degrees(end)

        arc = Arc((center.x, center.y), width, height, color=properties.color, linewidth=self.line_width,
                  angle=degrees(angle), theta1=start_degrees, theta2=end_degrees, zorder=self._get_z())
        self.ax.add_patch(arc) 
開發者ID:mozman,項目名稱:ezdxf,代碼行數:21,代碼來源:matplotlib_backend.py

示例11: get_angle_plot

# 需要導入模塊: from matplotlib import patches [as 別名]
# 或者: from matplotlib.patches import Arc [as 別名]
def get_angle_plot(line1, line2, radius=1, color=None, origin=(0, 0),
                   len_x_axis=1, len_y_axis=1):  # pragma: no cover

    l1xy = line1.get_xydata()
    # Angle between line1 and x-axis
    l1_xs = l1xy[:, 0]
    l1_ys = l1xy[:, 1]
    angle1 = np.degrees(np.arctan2(np.diff(l1_ys), np.diff(l1_xs)))

    l2xy = line2.get_xydata()
    # Angle between line2 and x-axis
    l2_xs = l2xy[:, 0]
    l2_ys = l2xy[:, 1]
    angle2 = np.degrees(np.arctan2(np.diff(l2_ys), np.diff(l2_xs)))

    theta1 = min(angle1, angle2)
    theta2 = max(angle1, angle2)

    if color is None:
        color = line1.get_color()  # Uses the color of line 1 if color parameter is not passed.
    return Arc(origin, len_x_axis * radius, len_y_axis * radius, 0, theta1, theta2, color=color) 
開發者ID:OpenMDAO,項目名稱:dymos,代碼行數:23,代碼來源:brachistochrone_fbd.py

示例12: plot

# 需要導入模塊: from matplotlib import patches [as 別名]
# 或者: from matplotlib.patches import Arc [as 別名]
def plot(self, ax, label=True):
        """Draws and labels the arc onto the passed Matplotlib axis.

        Args:
            ax: Matplotlib axis
            label (bool): if True, label the arc
        """
        ctr = self.actr
        vect1 = None
        sign = 1
        if self.concavity == 'concave':
            vect1 = self.pt(0)-ctr
        else:
            sign = -1
            vect1 = self.pt(1)-ctr
        rad = self.radius
        ang1 = (vect1.ang_deg())
        ang2 = ang1 + sign*self.get_ang()

        # matplotlib assumes ccw arc drawing, calculix assumes cw drawing
        a = AArc(xy=[ctr.y, ctr.x], width=2*rad, height=2*rad, angle=0,
                 theta1=ang1, theta2=ang2)
        ax.add_artist(a)
        if label:
            self.label(ax) 
開發者ID:spacether,項目名稱:pycalculix,代碼行數:27,代碼來源:geometry.py

示例13: __init__

# 需要導入模塊: from matplotlib import patches [as 別名]
# 或者: from matplotlib.patches import Arc [as 別名]
def __init__(self, axes, spine_type, path, **kwargs):
        """
        - *axes* : the Axes instance containing the spine
        - *spine_type* : a string specifying the spine type
        - *path* : the path instance used to draw the spine

        Valid kwargs are:
        %(Patch)s
        """
        super().__init__(**kwargs)
        self.axes = axes
        self.set_figure(self.axes.figure)
        self.spine_type = spine_type
        self.set_facecolor('none')
        self.set_edgecolor(rcParams['axes.edgecolor'])
        self.set_linewidth(rcParams['axes.linewidth'])
        self.set_capstyle('projecting')
        self.axis = None

        self.set_zorder(2.5)
        self.set_transform(self.axes.transData)  # default transform

        self._bounds = None  # default bounds
        self._smart_bounds = False

        # Defer initial position determination. (Not much support for
        # non-rectangular axes is currently implemented, and this lets
        # them pass through the spines machinery without errors.)
        self._position = None
        if not isinstance(path, matplotlib.path.Path):
            raise ValueError(
                "'path' must be an instance of 'matplotlib.path.Path'")
        self._path = path

        # To support drawing both linear and circular spines, this
        # class implements Patch behavior three ways. If
        # self._patch_type == 'line', behave like a mpatches.PathPatch
        # instance. If self._patch_type == 'circle', behave like a
        # mpatches.Ellipse instance. If self._patch_type == 'arc', behave like
        # a mpatches.Arc instance.
        self._patch_type = 'line'

        # Behavior copied from mpatches.Ellipse:
        # Note: This cannot be calculated until this is added to an Axes
        self._patch_transform = mtransforms.IdentityTransform() 
開發者ID:PacktPublishing,項目名稱:Mastering-Elasticsearch-7.0,代碼行數:47,代碼來源:spines.py

示例14: plot

# 需要導入模塊: from matplotlib import patches [as 別名]
# 或者: from matplotlib.patches import Arc [as 別名]
def plot(self, ax, chrom_region, region_start, region_end):
        """
        Makes and arc connecting two points on a linear scale representing
        interactions between Hi-C bins.
        """
        self.ax = ax

        from matplotlib.patches import Arc
        height = 1
        max_diameter = 0
        count = 0
        if chrom_region not in list(self.interval_tree):
            chrom_region = change_chrom_names(chrom_region)
        arcs_in_region = sorted(self.interval_tree[chrom_region][region_start:region_end])

        for idx, interval in enumerate(arcs_in_region):
            # skip arcs whose start and end are outside the plotted region
            if interval.begin < region_start and interval.end > region_end:
                continue

            if 'line_width' in self.properties:
                line_width = float(self.properties['line_width'])
            else:
                line_width = 0.5 * np.sqrt(interval.data)

            diameter = (interval.end - interval.begin)
            center = (interval.begin + interval.end) / 2
            if diameter > max_diameter:
                max_diameter = diameter
            count += 1
            ax.plot([center], [diameter])
            ax.add_patch(Arc((center, 0), diameter,
                             height*2, 0, 0, 180, color=self.properties['color'], lw=line_width))

        # increase max_diameter slightly to avoid cropping of the arcs.
#       max_diameter += max_diameter * 0.05
        height += height * 0.05
        log.debug("{} were arcs plotted".format(count))
        if 'orientation' in self.properties and self.properties['orientation'] == 'inverted':
            ax.set_ylim(height, 0.001)
        else:
            ax.set_ylim(-0.001, height)

        ax.set_xlim(region_start, region_end)
        log.debug('title is {}'.format(self.properties['title']))

        self.plot_label() 
開發者ID:GangCaoLab,項目名稱:CoolBox,代碼行數:49,代碼來源:arcs.py

示例15: __init__

# 需要導入模塊: from matplotlib import patches [as 別名]
# 或者: from matplotlib.patches import Arc [as 別名]
def __init__(self, axes, spine_type, path, **kwargs):
        """
        - *axes* : the Axes instance containing the spine
        - *spine_type* : a string specifying the spine type
        - *path* : the path instance used to draw the spine

        Valid kwargs are:
        %(Patch)s
        """
        super(Spine, self).__init__(**kwargs)
        self.axes = axes
        self.set_figure(self.axes.figure)
        self.spine_type = spine_type
        self.set_facecolor('none')
        self.set_edgecolor(rcParams['axes.edgecolor'])
        self.set_linewidth(rcParams['axes.linewidth'])
        self.set_capstyle('projecting')
        self.axis = None

        self.set_zorder(2.5)
        self.set_transform(self.axes.transData)  # default transform

        self._bounds = None  # default bounds
        self._smart_bounds = False

        # Defer initial position determination. (Not much support for
        # non-rectangular axes is currently implemented, and this lets
        # them pass through the spines machinery without errors.)
        self._position = None
        if not isinstance(path, matplotlib.path.Path):
            raise ValueError(
                "'path' must be an instance of 'matplotlib.path.Path'")
        self._path = path

        # To support drawing both linear and circular spines, this
        # class implements Patch behavior three ways. If
        # self._patch_type == 'line', behave like a mpatches.PathPatch
        # instance. If self._patch_type == 'circle', behave like a
        # mpatches.Ellipse instance. If self._patch_type == 'arc', behave like
        # a mpatches.Arc instance.
        self._patch_type = 'line'

        # Behavior copied from mpatches.Ellipse:
        # Note: This cannot be calculated until this is added to an Axes
        self._patch_transform = mtransforms.IdentityTransform() 
開發者ID:alvarobartt,項目名稱:twitter-stock-recommendation,代碼行數:47,代碼來源:spines.py


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