Exemplo n.º 1
0
 def normal_srcs(self):
     self.__debug("get:normal_srcs")
     s = self.__normal_srcs
     if s is None:
         self.__debug("get:normal_srcs:CacheMiss")
         p = {
             'color': self.color,
             'ec': 'w',
             'radius': (self.x_max - self.x_min) / self.x_ratio / 80
         }
         s = (Circle((-self.d, 0), **p), Circle((self.d, 0), **p))
         self.__normal_srcs = s
     return s
Exemplo n.º 2
0
 def zoom_srcs(self):
     self.__debug("get:zoom_srcs")
     s = self.__zoom_srcs
     if s is None:
         self.__debug("get:zoom_srcs:CacheMiss")
         p = {
             'color': self.color,
             'ec': 'w',
             'radius': (self.zoom.x_max - self.zoom.x_min) / 200
         }
         s = (Circle((-self.d, 0), **p), Circle((self.d, 0), **p))
         self.__zoom_srcs = s
     return s
Exemplo n.º 3
0
    def plot2(self, ant_radius, plot_radius=None, plot_radii=[]):
        if self.x is None or self.y is None:
            return
        fig, ax = plt.subplots(figsize=(8, 8))
        ax.set_aspect('equal')

        filled = False
        colour = 'k'
        radius = ant_radius
        for xy in zip(self.x, self.y):
            c = Circle(xy, radius=radius, fill=filled, color=colour)
            ax.add_artist(c)

        ax.plot(self.x, self.y, 'k+')

        for r in plot_radii:
            color = r[1] if isinstance(r, tuple) else 'r'
            radius = r[0] if isinstance(r, tuple) else r
            ax.add_artist(plt.Circle((0, 0), radius, fill=False, color=color))

        for path in self.poly_mask_path:
            patch = patches.PathPatch(path, facecolor='None', lw=1)
            ax.add_patch(patch)

        if plot_radius:
            ax.set_xlim(-plot_radius, plot_radius)
            ax.set_ylim(-plot_radius, plot_radius)

        plt.show()
        plt.close(fig)
Exemplo n.º 4
0
    def handle_click(event):
        x, y = event.xdata, event.ydata
        points.append((x, y))

        print('Point at (%d, %d)' % (x, y))
        ax = fig.gca()
        ax.add_artist(Circle((x, y), radius=50))
        show()
Exemplo n.º 5
0
 def half_circles(self, half_circle):
     #drawing border circles and regulation rod
     ax = gca()
     border_circle = Circle((half_circle.pos_x, half_circle.pos_y),
                            half_circle.radius,
                            fc='none',
                            ec='black')
     ax.add_artist(border_circle)
Exemplo n.º 6
0
def plot2():
    x1, y1, x2, y2, x3, y3, x4, y4, x_outer, y_outer = load_enu()
    fig, ax = _create_figure(left=0.12)

    # ax.add_artist(Circle((0, 0), radius=0.5e3, fill=False, color='0.5',
    #                      linestyle='-'))
    for i, xy in enumerate(zip(x1, y1)):
        ax.add_artist(Circle(xy, radius=35 / 2, fill=False, color='b', lw=1))
        # ax.text(xy[0], xy[1], ('%i' % i), va='center', ha='center', size=8)

    # Rings
    ax.add_artist(
        Circle((0, 0), radius=1.7e3, fill=False, color='0.5', linestyle='--'))
    num_ring = [21, 27, 21]
    color_ = ['r', 'r', 'r']
    for j in range(3):
        i0 = int(np.sum(num_ring[:j]))
        i1 = int(np.sum(num_ring[:j + 1]))
        x2_r = x2[i0:i1]
        y2_r = y2[i0:i1]
        angle_ = np.arctan2(y2_r, x2_r)
        sort_idx = np.argsort(angle_)
        x2_r = x2_r[sort_idx]
        y2_r = y2_r[sort_idx]
        for i, xy in enumerate(zip(x2_r, y2_r)):
            ax.add_artist(
                Circle(xy, radius=35 / 2, fill=True, color=color_[j], lw=1))
            ax.text(xy[0],
                    xy[1] + 50, ('R%i-%i' % (j, i)),
                    va='center',
                    ha='center',
                    size=8)

    # Spiral arms
    ax.add_artist(
        Circle((0, 0), radius=6.4e3, fill=False, color='0.5', linestyle='--'))
    for xy in zip(x3[::3], y3[::3]):
        ax.add_artist(Circle(xy, radius=35 / 2, fill=True, color='g', lw=1))
    for xy in zip(x3[1::3], y3[1::3]):
        ax.add_artist(Circle(xy, radius=35 / 2, fill=True, color='g', lw=1))
    for xy in zip(x3[2::3], y3[2::3]):
        ax.add_artist(Circle(xy, radius=35 / 2, fill=True, color='g', lw=1))

    # Outer stations
    for xy in zip(x4, y4):
        ax.add_artist(Circle(xy, radius=35 / 2, fill=True, color='k', lw=1))

    r_max = 2.0e3
    ax.set_xlim(-r_max, r_max)
    ax.set_ylim(-r_max, r_max)
    ax.set_xlabel('East (m)')
    ax.set_ylabel('North (m)')
    ax.grid(True)
    fig.savefig('ska1_v7_core_rings.eps')
    plt.close(fig)
Exemplo n.º 7
0
def plot1():
    x1, y1, x2, y2, x3, y3, x4, y4, x_outer, y_outer = load_enu()
    fig, ax = _create_figure()

    for i, xy in enumerate(zip(x1, y1)):
        ax.add_artist(Circle(xy, radius=35 / 2, fill=False, color='b', lw=1))
        ax.text(xy[0], xy[1], ('%i' % i), va='center', ha='center', size=8)
    ax.add_artist(
        Circle((0, 0), radius=0.5e3, fill=False, color='k', linestyle='--'))

    r_max = 0.5e3
    ax.set_xlim(-r_max, r_max)
    ax.set_ylim(-r_max, r_max)
    ax.set_xlabel('East (m)')
    ax.set_ylabel('North (m)')
    ax.grid(True)
    fig.savefig('ska1_v7_core.eps')
    plt.close(fig)
Exemplo n.º 8
0
 def plot_cover(self, axis, r, I=[], **kw):
     if 'c' in kw:
         kw['color'] = kw['c']
         del kw['c']
     kw['alpha'] = kw['alpha'] if 'alpha' in kw else 0.12
     kw['zorder'] = kw['zorder'] if 'zorder' in kw else 0
     kw['color'] = kw['color'] if 'color' in kw else 'black'
     I = I if len(I) else range(len(self.data))
     list(map(lambda i: axis.add_artist(Circle(self.data[i], r, **kw)), I))
Exemplo n.º 9
0
 def plot(self, ax):
     from matplotlib.pyplot import Circle
     for x, y in zip(self.x, self.y):
         circle = Circle((x, y),
                         self.min_spacing / 2,
                         color='k',
                         ls='--',
                         fill=False)
         ax.add_artist(circle)
Exemplo n.º 10
0
def show_association(fig, associations):
    ax = fig.gca()
    for association in associations:
        x, y = association[:2]
        ax.add_artist(Circle((x, y), radius=30, alpha=.65))

        for child in association[2:]:
            word, x_mid, y_mid = child
            ax.plot([x, x_mid], [y, y_mid], c='k')
Exemplo n.º 11
0
def phi(w, f, o):
    fig1 = plt.figure()
    ax1 = fig1.gca()
    im = ax1.contourf(w.xv, w.yv, f.phi, levels=10)
    fig1.colorbar(im, ax=ax1)
    circ = Circle(o.c, o.r, fill=False)
    ax1.add_patch(circ)
    ax1.axis("equal")
    plt.title("Phi")
Exemplo n.º 12
0
            def drawc(c):

                # Draw circle colured according to partition
                gca().add_patch(
                    Circle((c.xc[0], c.xc[1]),
                           radius=c.r,
                           color=hsv_to_rgb(random(), 1, 1),
                           fill=False))
                axis('equal')
                draw()
Exemplo n.º 13
0
def plot3():
    x1, y1, x2, y2, x3, y3, x4, y4, x_outer, y_outer = load_enu()
    fig, ax = _create_figure(left=0.12)

    # ax.add_artist(Circle((0, 0), radius=0.5e3, fill=False, color='0.5',
    #                      linestyle='-'))
    for i, xy in enumerate(zip(x1, y1)):
        ax.add_artist(Circle(xy, radius=35 / 2, fill=False, color='b', lw=1))
        # ax.text(xy[0], xy[1], ('%i' % i), va='center', ha='center', size=8)

    # Rings
    # ax.annotate('Rings', xy=(1.7e3/2**0.5, 1.7e3/2**0.5),
    #             xytext=(3e3, 3e3),
    #             arrowprops=dict(facecolor='k', shrink=0.0001))
    # ax.add_artist(Circle((0, 0), radius=1.7e3, fill=False, color='0.5',
    #                      linestyle='-'))
    for xy in zip(x2, y2):
        ax.add_artist(Circle(xy, radius=35 / 2, fill=True, color='r', lw=1))

    # Spiral arms
    ax.add_artist(
        Circle((0, 0), radius=6.4e3, fill=False, color='0.5', linestyle='--'))
    for i, xy in enumerate(zip(x3[::3], y3[::3])):
        ax.add_artist(Circle(xy, radius=35 / 2, fill=True, color='g', lw=1))
        # if i > 10 or i == 0 or i == 5:
        #     ax.text(xy[0] - 50, xy[1], ('S0-%i' % i), va='center', ha='right',
        #             size=6)
        if i == 20:
            ax.text(xy[0] + 200, xy[1], 'S0-[0,30]', size=10, va='center')

    for i, xy in enumerate(zip(x3[1::3], y3[1::3])):
        ax.add_artist(Circle(xy, radius=35 / 2, fill=True, color='g', lw=1))
        # if i > 10 or i == 0 or i == 5:
        #     ax.text(xy[0] - 50, xy[1], ('E0-%i' % i), va='center', ha='right',
        #             size=6)
        if i == 20:
            ax.text(xy[0] + 200, xy[1], 'E0-[0,30]', size=10, va='center')

    for i, xy in enumerate(zip(x3[2::3], y3[2::3])):
        ax.add_artist(Circle(xy, radius=35 / 2, fill=True, color='g', lw=1))
        # if i > 10 or i == 0 or i == 5:
        #     ax.text(xy[0] - 50, xy[1], ('N0-%i' % i), va='center', ha='right',
        #             size=6)
        if i == 20:
            ax.text(xy[0] + 200, xy[1], 'N0-[0,30]', size=10, va='center')

    # Outer stations
    for xy in zip(x4, y4):
        ax.add_artist(Circle(xy, radius=35 / 2, fill=True, color='k', lw=1))

    r_max = 6.4e3
    ax.set_xlim(-r_max, r_max)
    ax.set_ylim(-r_max, r_max)
    ax.set_xlabel('East (m)')
    ax.set_ylabel('North (m)')
    ax.grid(True)
    fig.savefig('ska1_v7_core_area.eps')
    plt.close(fig)
Exemplo n.º 14
0
def velocity(w, f, o):
    fig1 = plt.figure()
    ax1 = fig1.gca()
    ax1.streamplot(w.xv, w.yv, f.Vx, f.Vy, density=[0.5, 1])
    im = ax1.pcolormesh(w.xv, w.yv, f.V, cmap=cmap)
    fig1.colorbar(im, ax=ax1)
    circ = Circle(o.c, o.r, fill=False)
    ax1.add_patch(circ)
    ax1.axis("equal")
    plt.title("Velocity (m/s)")
Exemplo n.º 15
0
Arquivo: T1.py Projeto: Nuos/oBB
            def drawc(c, col):

                # Draw circle
                gca().add_patch(
                    Circle((c.xc[0], c.xc[1]),
                           radius=c.r,
                           color=col,
                           fill=False))
                axis('equal')
                draw()
Exemplo n.º 16
0
def pressure(w, f, o):
    fig1 = plt.figure()
    ax1 = fig1.gca()
    ax1.streamplot(w.xv, w.yv, f.Vx, f.Vy, density=[0.2, 0.5])
    im = ax1.pcolormesh(w.xv, w.yv, f.p, cmap=cmap)
    fig1.colorbar(im, ax=ax1)
    circ = Circle(o.c, o.r, fill=False)
    ax1.add_patch(circ)
    ax1.axis("equal")
    plt.title("Pressure (Pa)")
Exemplo n.º 17
0
    def plot(self):
        '''
        Draws dots, lines, triangles in the left canvas.
        :return: None
        '''
        self.ax.set_facecolor('lightgray')
        self.ax.clear()
        self.ax.set_xlim([0, 1])
        self.ax.set_ylim([0, 1])

        multiPoligon = constructTriangleArray(drawingData.triangles)

        # plot triangles
        if isinstance(multiPoligon, Polygon):
            x, y = multiPoligon.exterior.coords.xy
            self.ax.fill(
                x,
                y,
                'b',
                alpha=0.5,
            )
        else:
            for i in multiPoligon:
                x, y = i.exterior.coords.xy
                self.ax.fill(x, y, 'b', alpha=0.5)

        # plot lines
        for ((x1, y1), (x2, y2)) in self.data.lines:
            if ((x2 - x1) * (x2 - x1) + (y2 - y1) *
                (y2 - y1) <= drawingData.epsilon * drawingData.epsilon):
                self.ax.plot([x1, x2], [y1, y2], "black")

        # plot dots and circles
        for dot in self.data.dots:
            self.ax.plot([dot[0]], [dot[1]], 'bo')

        # plot circles
        if drawingData.showCircles:
            for dot in self.data.dots:
                self.ax.add_artist(
                    Circle((dot[0], dot[1]),
                           drawingData.epsilon / 2,
                           color='orange',
                           fill=False,
                           linewidth=3))

        self.epsilon_line.remove()

        lines = self.ay.plot([drawingData.epsilon, drawingData.epsilon],
                             [0, self.num], "black")

        self.epsilon_line = lines.pop()

        self.draw()
Exemplo n.º 18
0
 def plot(self, ax=None):
     from matplotlib.pyplot import Circle
     import matplotlib.pyplot as plt
     ax = ax or plt.gca()
     for x, y in zip(self.x, self.y):
         circle = Circle((x, y),
                         self.min_spacing / 2,
                         color='k',
                         ls='--',
                         fill=False)
         ax.add_artist(circle)
Exemplo n.º 19
0
 def fuel_cells(self, status, fill_color):
     #drawing fuel cells with selected status IN or OUT
     ax = gca()
     print('Drawing image starts: Cells ' + status)
     for f in self.fuel_elimination.evaluate():
         viz_x = f['coord_x']
         viz_y = f['coord_y']
         viz_r = f['coord_r']
         if f['result'] == status:
             fuel = Circle((viz_x, viz_y), viz_r, color=fill_color)
             ax.add_artist(fuel)
Exemplo n.º 20
0
class Circle(OriginalCircle):
    """Defines a circle in R^2.

    This circle is drawable.
    """
    def __init__(self, *args, squared: bool = False, **kwargs):
        """Initialize a new circle.

        The circle can be given either as three (non-colinear) points or as a
        point an a (potentially squared) radius.
        """
        super(Circle, self).__init__(*args, squared=squared)

        if 'color' not in kwargs:
            kwargs['color'] = 'grey'
        if 'fill' not in kwargs:
            kwargs['fill'] = True
        if 'zorder' not in kwargs:
            kwargs['zorder'] = 50
        if 'alpha' not in kwargs:
            kwargs['alpha'] = .2

        self.circle = DrawCircle(self.center.tuple(), self.radius, **kwargs)
        gca().add_patch(self.circle)
        draw()

    @OriginalCircle.radius.setter
    def radius(self, value: float) -> None:
        """Set the radius of the circle."""
        super(Circle, self.__class__).radius.__set__(self, value)

        self.circle.set_radius(self.radius)
        draw()

    @OriginalCircle.radius2.setter
    def radius2(self, value: float) -> None:
        """Set the squared radius of the circle."""
        super(Circle, self.__class__).radius2.__set__(self, value)

        self.circle.set_radius(self.radius)
        draw()
Exemplo n.º 21
0
    def __init__(self, id, og_anim_bucket):
        """Stores user values"""

        # Used to differentiate users
        self.id = id
        # Used to track suspicions
        self.suspicions = []
        # Used to track location
        self.points = []

        if og_anim_bucket:
            center_x = og_anim_bucket.patch_center()
        else:
            center_x = self.disconnected_location[0]

        self.patch = Circle((center_x, 5),
                            Anim_User.patch_radius,
                            fc=Anim_User.og_face_color)
        self.text = text(center_x,
                         5,
                         self.id,
                         horizontalalignment="center",
                         verticalalignment="center")
Exemplo n.º 22
0
 def draw_source(self, ax):
     source = self
     c1 = np.asarray(source.get_loop_list())
     c2 = c1 * [1, -1, 1]
     try:
         dia = np.sqrt(
             np.power(c1[0][0] - c1[1][0], 2) +
             np.power(c1[0][1] - c1[1][1], 2))
         dia = min(dia, 1.0)
     except IndexError:
         dia = 1.0
     neg = np.asarray([1, -1])
     poly = Polygon(
         (source.start, source.end, source.end * neg, source.start * neg),
         color=[0.4, 0.4, 0.4, 0.25],
         zorder=0)
     ax.add_artist(poly)
     for loop in c1:
         circle = Circle((loop[0], loop[1]), dia / 2, color='r', fill=None)
         ax.add_artist(circle)
     for loop in c2:
         circle = Circle((loop[0], loop[1]), dia / 2, color='r', fill=None)
         ax.add_artist(circle)
Exemplo n.º 23
0
def robot_draw(ax, x, y, theta, d=0.25, **kwargs):

    dx = d * np.cos(theta)
    dy = d * np.sin(theta)

    opt = {
        'head_width': 0.3,
        'head_length': 0.3,
        'width': 0.05,
        'length_includes_head': True
    }

    color = kwargs.pop('color', kwargs.pop('colour', 'blue'))
    circle = Circle((x, y), d, fill=False, color=color, **kwargs)
    ax.add_artist(circle)
    ax.arrow(x, y, dx, dy, **opt, color=color)
Exemplo n.º 24
0
def plot_2D(result,
            time=None,
            radius=None,
            edges=False,
            paths='black',
            center="Default"):
    from scipy.spatial import distance
    print("Displaying results...")
    fig, ax = subplots()

    for p in result:
        if paths is not None:
            plot(p[0], p[1], linewidth=1, color=paths, alpha=0.2, zorder=1)
        if time is not None:
            plot(p[0][time],
                 p[1][time],
                 'o',
                 markersize=2.5,
                 color="black",
                 zorder=3)
        if radius is not None and time is not None:
            ax.add_artist(
                Circle((p[0][time], p[1][time]),
                       radius,
                       linestyle='--',
                       color='k',
                       alpha=0.5,
                       fill=False,
                       zorder=2))

    if time is not None and edges is not None:
        edge = []
        for i in result:
            i_t = [i[0][time], i[1][time]]
            for j in result:
                j_t = [j[0][time], j[1][time]]
                if i is not j and distance.euclidean(i_t, j_t) < edges:
                    edge.append([tuple(i_t), tuple(j_t)])
        lines = LineCollection(edge, color='k', linewidth=1, zorder=3)
        ax.add_collection(lines)

    ax.autoscale()
    axis("equal")
    show()
Exemplo n.º 25
0
    def __init__(self, *args, squared: bool = False, **kwargs):
        """Initialize a new circle.

        The circle can be given either as three (non-colinear) points or as a
        point an a (potentially squared) radius.
        """
        super(Circle, self).__init__(*args, squared=squared)

        if 'color' not in kwargs:
            kwargs['color'] = 'grey'
        if 'fill' not in kwargs:
            kwargs['fill'] = True
        if 'zorder' not in kwargs:
            kwargs['zorder'] = 50
        if 'alpha' not in kwargs:
            kwargs['alpha'] = .2

        self.circle = DrawCircle(self.center.tuple(), self.radius, **kwargs)
        gca().add_patch(self.circle)
        draw()
Exemplo n.º 26
0
 def drawNetGraph(self, rawNet):
     self.ax.cla()
     colors = [
         'b' if n in rawNet.switches else 'r' for n in rawNet.graphRAW
     ]
     self.pos = nx.spring_layout(rawNet.graphRAW,
                                 scale=0.1,
                                 seed=239,
                                 iterations=200,
                                 k=1)
     nx.draw_networkx_nodes(rawNet.graphRAW,
                            self.pos,
                            node_color=colors,
                            node_size=500,
                            alpha=0.5,
                            ax=self.ax)
     nx.draw_networkx_edges(rawNet.graphRAW,
                            self.pos,
                            width=1,
                            alpha=0.5,
                            edge_color='k',
                            ax=self.ax)
     nx.draw_networkx_labels(rawNet.graphRAW,
                             self.pos,
                             labels=rawNet.labels,
                             font_size=11,
                             ax=self.ax)
     if not (rawNet.selected in rawNet.hosts
             or rawNet.selected in rawNet.switches):
         rawNet.selected = None
     if rawNet.selected:
         x, y = self.pos[rawNet.selected]
         stype = rawNet.selected in rawNet.switches
         circle = Circle((x, y),
                         0.01,
                         lw=2,
                         fill=False,
                         ec="red" if stype else 'blue',
                         linestyle='--')
         self.ax.add_artist(circle)
     self.nGraph.draw()
Exemplo n.º 27
0
    def plot(self, ax=None):
        from matplotlib.pyplot import Circle
        import matplotlib.pyplot as plt
        ax = ax or plt.gca()

        def get_xy(xy):
            if not hasattr(self, xy):
                setattr(
                    self, xy,
                    dict(self.list_inputs(out_stream=None))
                    [f'pre_constraints.{self.name}.{xy}']['value'])
            xy = getattr(self, xy)
            return xy if not isinstance(xy, tuple) else xy[0]

        for x, y in zip(get_xy('x'), get_xy('y')):
            circle = Circle((x, y),
                            self.min_spacing / 2,
                            color='k',
                            ls='--',
                            fill=False)
            ax.add_artist(circle)
Exemplo n.º 28
0
def draw_network(network,omit=[],arrowsize=15,font_size='small',arrowstyle='->',database_file='hanford.dat',do_legend=True,pos=None,node_colors=node_colors,node_alpha=0.8,label_edges=False,namechanges={},**kwargs):
    to_draw=network.copy()
    for p in network.nodes:
        if network.nodes[p]['kind'] in omit or p in omit or p in ['HRimm','Tracer']:
            to_draw.remove_node(p)
        elif network.nodes[p]['kind'] == 'surf_complex':
            for cplx in network.nodes[p]['complexes']:
                to_draw=nx.compose(get_reaction_from_database(cplx,'surf_complex',filename=database_file),to_draw)
        elif network.nodes[p]['kind'] not in ['primary','immobile','implicit','sorbed']:
            to_draw=nx.compose(get_reaction_from_database(p,network.nodes[p]['kind'],filename=database_file),to_draw)
        
    # Get rid of nodes added from database reactions that we want removed
    to_draw.remove_nodes_from([node for node in to_draw.nodes if to_draw.nodes('kind')[node] is None])
            
    if pos is None:
        pos=nx.drawing.nx_agraph.graphviz_layout(to_draw,prog='dot')
    nodecats=categorize_nodes(to_draw)  
    nodecolors=[node_colors[nodecat] for nodecat in nodecats]
    
    nx.draw_networkx_nodes(to_draw,pos=pos,with_labels=False,nodes=to_draw.nodes,node_color=nodecolors,alpha=node_alpha,**kwargs)
    nx.draw_networkx_edges(to_draw,pos=pos,arrowsize=arrowsize,arrowstyle=arrowstyle,**kwargs)
    nx.draw_networkx_labels(to_draw,pos=pos,labels={n:namechanges.get(n,n) for n in to_draw.nodes},font_size=font_size,**kwargs)
    
    if label_edges:            
        nx.draw_networkx_edge_labels(to_draw,pos=pos,edge_labels=dict([((e[0],e[1]),e[2]) for e in to_draw.edges(data='name')]),font_size=font_size,fontstyle='italic')
                
    if do_legend:
        from matplotlib.pyplot import Circle,legend
        legend_handles=[]
        legend_labels=[]
        
        for num,node in enumerate(to_draw.nodes):
            if nodecats[num] not in legend_labels:
                legend_labels.append(namechanges.get(nodecats[num],nodecats[num]))
                legend_handles.append(Circle((0,0),radius=5,facecolor=nodecolors[num]))
                
        legend(handles=legend_handles,labels=legend_labels,fontsize='medium',title='Component types')
    
    return to_draw
Exemplo n.º 29
0
def saveImage(in_path, out_path, x, y, a, b, t):
    from matplotlib.patches import Ellipse
    import matplotlib.pyplot as plt

    img = cv2.imread(in_path, 0)

    ells = Ellipse(
        (x, y),
        a * 2,
        b * 2,
        t,
        edgecolor='red',
        facecolor='none',
    )
    plt.imshow(img, cmap='gray')
    from matplotlib.pyplot import Circle
    patches = [ells, Circle((x, y), radius=2, color='red')]
    ax = plt.gca()
    for p in patches:
        ax.add_patch(p)
    plt.savefig(out_path)
    plt.cla()
Exemplo n.º 30
0
    def polezero_plot(self, axes=None, **kwargs):

        from matplotlib.pyplot import Circle
        
        def annotate(axes, roots, offset=None):
            if offset is None:
                xmin, xmax = axes.get_xlim()
                offset = (xmax - xmin) / 27
        
            plist = list(roots)
            for root in set(roots):
                num = plist.count(root)
                if num > 1:
                    axes.text(root.real + offset, root.imag + offset, '%d' % num)

        if axes is None:
            fig, axes = subplots(1)

        axes.grid(True)
        axes.set_xlabel('Real')
        axes.set_ylabel('Imaginary')

        poles = self.poles
        axes.plot(poles.real, poles.imag, 'C0x', ms=20)
        annotate(axes, poles)

        zeros = self.zeros
        axes.plot(zeros.real, zeros.imag, 'C0o', ms=20, fillstyle='none')
        annotate(axes, zeros)        

        axes.add_artist(Circle((0, 0), 1, color='blue', linestyle='--', fill=False))
        a = np.hstack((poles, zeros))

        bbox = axes.get_window_extent()
        aspect = bbox.width / bbox.height
        axes.set_xlim(-1.2, 1.2)
        axes.set_ylim(-1.2, 1.2)