python类patches()的实例源码

phot_panel.py 文件源码 项目:CAAPR 作者: Stargrazer82301 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def redraw_overplot_on_image(self, *args):
        if self.star_center_patch is not None:
            self.ztv_frame.primary_image_panel.axes.patches.remove(self.star_center_patch)
        if self.star_aperture_patch is not None:
            self.ztv_frame.primary_image_panel.axes.patches.remove(self.star_aperture_patch)
        if self.sky_aperture_patch is not None:
            self.ztv_frame.primary_image_panel.axes.patches.remove(self.sky_aperture_patch)
        self.star_center_patch = Circle([self.xcentroid, self.ycentroid], 0.125, color=self.aprad_color)
        self.ztv_frame.primary_image_panel.axes.add_patch(self.star_center_patch)
        self.star_aperture_patch = Circle([self.xcentroid, self.ycentroid], self.aprad, color=self.aprad_color, alpha=self.alpha)
        self.ztv_frame.primary_image_panel.axes.add_patch(self.star_aperture_patch)
        self.sky_aperture_patch = Wedge([self.xcentroid, self.ycentroid], self.skyradout, 0., 360., 
                                        width=self.skyradout - self.skyradin, color=self.skyrad_color, alpha=self.alpha)
        self.ztv_frame.primary_image_panel.axes.add_patch(self.sky_aperture_patch)
        self.ztv_frame.primary_image_panel.figure.canvas.draw()
        self.hideshow_button.SetLabel(u"Hide")
redwood.py 文件源码 项目:pauvre 作者: conchoecia 项目源码 文件源码 阅读 39 收藏 0 点赞 0 评论 0
def plotArc(start_angle, stop_angle, radius, width, **kwargs):
    """ write a docstring for this function"""
    numsegments = 100
    theta = np.radians(np.linspace(start_angle+90, stop_angle+90, numsegments))
    centerx = 0
    centery = 0
    x1 = -np.cos(theta) * (radius)
    y1 = np.sin(theta) * (radius)
    stack1 = np.column_stack([x1, y1])
    x2 = -np.cos(theta) * (radius + width)
    y2 = np.sin(theta) *  (radius + width)
    stack2 = np.column_stack([np.flip(x2, axis=0), np.flip(y2,axis=0)])
    #add the first values from the first set to close the polygon
    np.append(stack2, [[x1[0],y1[0]]], axis=0)
    arcArray = np.concatenate((stack1,stack2), axis=0)
    return patches.Polygon(arcArray, True, **kwargs), ((x1, y1), (x2, y2))
plot_panel.py 文件源码 项目:CAAPR 作者: Stargrazer82301 项目源码 文件源码 阅读 30 收藏 0 点赞 0 评论 0
def redraw_overplot_on_image(self, msg=None):
        if self.primary_image_patch is not None:
            self.ztv_frame.primary_image_panel.axes.patches.remove(self.primary_image_patch)
        if self.start_pt == self.end_pt:
            path = Path([self.start_pt, self.start_pt + (0.5, 0.),
                         self.start_pt, self.start_pt + (-0.5, 0.), 
                         self.start_pt, self.start_pt + (0., 0.5), 
                         self.start_pt, self.start_pt + (0., -0.5), self.start_pt], 
                        [Path.MOVETO, Path.LINETO, Path.LINETO, Path.LINETO, Path.LINETO, 
                         Path.LINETO, Path.LINETO, Path.LINETO, Path.LINETO])
        else:
            path = Path([self.start_pt, self.end_pt], [Path.MOVETO, Path.LINETO])
        self.primary_image_patch = PathPatch(path, color='magenta', lw=1)
        self.ztv_frame.primary_image_panel.axes.add_patch(self.primary_image_patch)
        self.ztv_frame.primary_image_panel.figure.canvas.draw()
        self.hideshow_button.SetLabel(u"Hide")
UsefulUtils.py 文件源码 项目:FoundryDataBrowser 作者: ScopeFoundry 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def draw_roi(x1, y1, x2, y2, **draw_params):
    codes = [Path.MOVETO, Path.LINETO, Path.LINETO, Path.LINETO, Path.CLOSEPOLY]

    ax = plt.gca()

    # Form a path
    verts = [(x1, y1),
             (x1, y2),
             (x2, y2),
             (x2, y1),
             (0, 0)]
    path = Path(verts, codes)

    # Draw the BG region on the image
    patch = patches.PathPatch(path, **draw_params)
    ax.add_patch(patch)
frameview.py 文件源码 项目:SamuROI 作者: samuroi 项目源码 文件源码 阅读 33 收藏 0 点赞 0 评论 0
def create_outlined_artist(self, mask, color, **kwargs):
        artist = matplotlib.patches.Polygon(xy=mask.outline - 0.5, lw=1, picker=True, fill=False, color='gray',
                                            **kwargs)

        artist.color = color
        artist.mask = mask

        # todo: make the branches children a polygonCollection for better performance

        def set_selected(self, a):
            if a is True:
                self.set_linewidth(5)
                self.set_edgecolor(self.color)
            else:
                self.set_linewidth(1)
                self.set_edgecolor('gray')

        artist.set_selected = types.MethodType(set_selected, artist)
        self.__artists[mask] = artist
        self.axes.add_artist(artist)

        self.create_outlined_child_artits(parent=mask)
frameview.py 文件源码 项目:SamuROI 作者: samuroi 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def create_circle_artist(self, mask, color, **kwargs):
        artist = matplotlib.patches.Circle(radius=mask.radius, xy=mask.center - 0.5, lw=1, picker=True, fill=False,
                                           color='gray', **kwargs)

        artist.color = color
        artist.mask = mask

        def set_selected(self, a):
            if a is True:
                self.set_linewidth(5)
                self.set_edgecolor(self.color)
            else:
                self.set_linewidth(1)
                self.set_edgecolor('gray')

        artist.set_selected = types.MethodType(set_selected, artist)
        self.__artists[mask] = artist
        self.axes.add_artist(artist)
faster_rcnn_conv5.py 文件源码 项目:tf-Faster-RCNN 作者: kevinjliang 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def vis_detections(self, im, class_name, gt_boxes, dets):
        """Visual debugging of detections."""
        import matplotlib
        matplotlib.use('TkAgg')  # For Mac OS
        import matplotlib.pyplot as plt
        import matplotlib.patches as patches
        fig, ax = plt.subplots(1)
        for i in range(np.minimum(10, dets.shape[0])):
            bbox = dets[i,1:]
            print(bbox)
            ax.imshow(np.squeeze(im), cmap="gray")
            self.plot_patch(ax, patches, bbox, gt=False)
        plt.title(class_name)
        self.plot_patch(ax, patches, gt_boxes[0][:4], gt=True)

        # Display Final composite image
        plt.show()
plot_yields.py 文件源码 项目:poreduck 作者: alexiswl 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def plot_pore_yield_hist():
    # Close any previous plots
    plt.close('all')
    num_bins = 50
    new_yield_data = ALL_READS.groupby(["channel", "mux"])['seq_length'].sum()
    fig, ax = plt.subplots(1)
    (n, bins, patches) = ax.hist(new_yield_data, num_bins, weights=None,
                                 # [1],#channels_by_yield_df['seq_length'],
                                 normed=1, facecolor='blue', alpha=0.76)
    ax.xaxis.set_major_formatter(FuncFormatter(x_hist_to_human_readable))

    def y_muxhist_to_human_readable(y, position):
        # Get numbers of reads per bin in the histogram
        s = humanfriendly.format_size((bins[1]-bins[0])*y*new_yield_data.count(), binary=False)
        return reformat_human_friendly(s)
    ax.yaxis.set_major_formatter(FuncFormatter(y_muxhist_to_human_readable))

    # Set the titles and axis labels
    ax.set_title(f"Yield by pore {SAMPLE_NAME}")
    ax.grid(color='black', linestyle=':', linewidth=0.5)
    ax.set_xlabel("Yield in single pore")
    ax.set_ylabel("Pores per bin")
    # Ensure labels are not missed.
    fig.tight_layout()
    savefig(os.path.join(PLOTS_DIR, f"{SAMPLE_NAME.replace(' ', '_')}_hist_yield_by_pore.png"))
marginplot.py 文件源码 项目:pauvre 作者: conchoecia 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def generate_histogram(panel, data_list, max_plot_length, min_plot_length,
                       bin_interval, hist_horizontal=True,
                       left_spine=True, bottom_spine=True,
                       top_spine=False, right_spine=False, x_label=None,
                       y_label=None):

    bins = np.arange(0, max_plot_length, bin_interval)

    bin_values, bins2 = np.histogram(data_list, bins)

    # hist_horizontal is used for quality
    if hist_horizontal:
        panel.set_xlim([min_plot_length, max_plot_length])
        panel.set_ylim([0, max(bin_values * 1.1)])
    # and hist_horizontal == Fale is for read length
    else:
        panel.set_xlim([0, max(bin_values * 1.1)])
        panel.set_ylim([min_plot_length, max_plot_length])

    # Generate histogram bin patches, depending on whether we're plotting
    # vertically or horizontally
    _generate_histogram_bin_patches(panel, bins, bin_values, hist_horizontal)

    panel.spines['left'].set_visible(left_spine)
    panel.spines['bottom'].set_visible(bottom_spine)
    panel.spines['top'].set_visible(top_spine)
    panel.spines['right'].set_visible(right_spine)

    if y_label is not None:
        panel.set_ylabel(y_label)
    if x_label is not None:
        panel.set_xlabel(x_label)
DCWidgetResLayer2_5D.py 文件源码 项目:em_examples 作者: geoscixyz 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def addCylinder2Mod(xc,zc,r,modd,sigCylinder):

    # Get points for cylinder outline
    cylinderPoints = getCylinderPoints(xc,zc,r)
    mod = copy.copy(modd)

    verts = []
    codes = []
    for ii in range(0,cylinderPoints.shape[0]):
        verts.append(cylinderPoints[ii,:])

        if(ii == 0):
            codes.append(Path.MOVETO)
        elif(ii == cylinderPoints.shape[0]-1):
            codes.append(Path.CLOSEPOLY)
        else:
            codes.append(Path.LINETO)

    path = Path(verts, codes)
    CCLocs = mesh.gridCC
    insideInd = np.where(path.contains_points(CCLocs))

    # #Check selected cell centers by plotting
    # # print insideInd
    # fig = plt.figure()
    # ax = fig.add_subplot(111)
    # patch = patches.PathPatch(path, facecolor='none', lw=2)
    # ax.add_patch(patch)
    # plt.scatter(CCLocs[insideInd,0],CCLocs[insideInd,1])
    # ax.set_xlim(-40,40)
    # ax.set_ylim(-35,0)
    # plt.axes().set_aspect('equal')
    # plt.show()

    mod[insideInd] = sigCylinder
    return mod
DCWidgetResLayer2_5D.py 文件源码 项目:em_examples 作者: geoscixyz 项目源码 文件源码 阅读 37 收藏 0 点赞 0 评论 0
def addPlate2Mod(xc,zc,dx,dz,rotAng,modd,sigPlate):
    # use matplotlib paths to find CC inside of polygon
    plateCorners = getPlateCorners(xc,zc,dx,dz,rotAng)
    mod = copy.copy(modd)

    verts = [
        (plateCorners[0,:]), # left, top
        (plateCorners[1,:]), # right, top
        (plateCorners[3,:]), # right, bottom
        (plateCorners[2,:]), # left, bottom
        (plateCorners[0,:]), # left, top (closes polygon)
        ]

    codes = [Path.MOVETO,
             Path.LINETO,
             Path.LINETO,
             Path.LINETO,
             Path.CLOSEPOLY,
             ]

    path = Path(verts, codes)
    CCLocs = mesh.gridCC
    insideInd = np.where(path.contains_points(CCLocs))

    #Check selected cell centers by plotting
    # print insideInd
    # fig = plt.figure()
    # ax = fig.add_subplot(111)
    # patch = patches.PathPatch(path, facecolor='none', lw=2)
    # ax.add_patch(patch)
    # plt.scatter(CCLocs[insideInd,0],CCLocs[insideInd,1])
    # ax.set_xlim(-10,10)
    # ax.set_ylim(-20,0)
    # plt.axes().set_aspect('equal')
    # plt.show()

    mod[insideInd] = sigPlate
    return mod
DCWidgetPlate_2D.py 文件源码 项目:em_examples 作者: geoscixyz 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def createPlateMod(xc, zc, dx, dz, rotAng, sigplate, sighalf):
    # use matplotlib paths to find CC inside of polygon
    plateCorners = getPlateCorners(xc,zc,dx,dz,rotAng)

    verts = [
        (plateCorners[0,:]), # left, top
        (plateCorners[1,:]), # right, top
        (plateCorners[3,:]), # right, bottom
        (plateCorners[2,:]), # left, bottom
        (plateCorners[0,:]), # left, top (closes polygon)
        ]

    codes = [Path.MOVETO,
             Path.LINETO,
             Path.LINETO,
             Path.LINETO,
             Path.CLOSEPOLY,
             ]

    path = Path(verts, codes)
    CCLocs = mesh.gridCC
    insideInd = np.where(path.contains_points(CCLocs))

    #Check selected cell centers by plotting
    # print insideInd
    # fig = plt.figure()
    # ax = fig.add_subplot(111)
    # patch = patches.PathPatch(path, facecolor='none', lw=2)
    # ax.add_patch(patch)
    # plt.scatter(CCLocs[insideInd,0],CCLocs[insideInd,1])
    # ax.set_xlim(-10,10)
    # ax.set_ylim(-20,0)
    # plt.axes().set_aspect('equal')
    # plt.show()

    mtrue = sighalf*np.ones([mesh.nC,])
    mtrue[insideInd] = sigplate
    mtrue = np.log(mtrue)
    return mtrue
DCWidgetPlate2_5D.py 文件源码 项目:em_examples 作者: geoscixyz 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def createPlateMod(xc, zc, dx, dz, rotAng, sigplate, sighalf):
    # use matplotlib paths to find CC inside of polygon
    plateCorners = getPlateCorners(xc,zc,dx,dz,rotAng)

    verts = [
        (plateCorners[0,:]), # left, top
        (plateCorners[1,:]), # right, top
        (plateCorners[3,:]), # right, bottom
        (plateCorners[2,:]), # left, bottom
        (plateCorners[0,:]), # left, top (closes polygon)
        ]

    codes = [Path.MOVETO,
             Path.LINETO,
             Path.LINETO,
             Path.LINETO,
             Path.CLOSEPOLY,
             ]

    path = Path(verts, codes)
    CCLocs = mesh.gridCC
    insideInd = np.where(path.contains_points(CCLocs))

    #Check selected cell centers by plotting
    # print insideInd
    # fig = plt.figure()
    # ax = fig.add_subplot(111)
    # patch = patches.PathPatch(path, facecolor='none', lw=2)
    # ax.add_patch(patch)
    # plt.scatter(CCLocs[insideInd,0],CCLocs[insideInd,1])
    # ax.set_xlim(-10,10)
    # ax.set_ylim(-20,0)
    # plt.axes().set_aspect('equal')
    # plt.show()

    mtrue = sighalf*np.ones([mesh.nC,])
    mtrue[insideInd] = sigplate
    mtrue = np.log(mtrue)
    return mtrue
embedding.py 文件源码 项目:Dragonfly 作者: duaneloh 项目源码 文件源码 阅读 29 收藏 0 点赞 0 评论 0
def end_track_positions(self):
        pos = np.array(self.positions)
        if pos.size == 0:
            return
        try:
            xnum = int(self.x_axis_num.text())
            ynum = int(self.y_axis_num.text())
        except ValueError:
            sys.stderr.write('Need axes numbers to be integers\n')
            return
        pos = np.append(pos, pos[-1]).reshape(-1,2)
        self.path_list.append(matplotlib.path.Path(pos, closed=True))
        points_inside = np.array([self.path_list[-1].contains_point((p[xnum], p[ynum])) for p in self.embed])
        sys.stderr.write('%d/%d frames inside ROI %d\n' % (points_inside.sum(), len(points_inside), len(self.points_inside_list)))
        self.points_inside_list.append(self.conversion.indices[np.where(points_inside)[0]])

        self.roi_list.append(
            matplotlib.patches.PathPatch(
                self.path_list[-1],
                color='white',
                fill=False,
                linewidth=2.,
                figure=self.frame.fig
            )
        )
        self.frame.fig.get_axes()[0].add_artist(self.roi_list[-1])
        for p in self.click_points_list:
            p.remove()
        self.frame.canvas.draw()

        self.frame.canvas.mpl_disconnect(self.connect_id)
        self.positions = []
        self.click_points_list = []
        if self.roi_summary is None:
            self.add_roi_frame()
        elif self.roi_summary.text() == '':
            self.roi_frame.show()
        self.gen_roi_summary()
        self.add_roi_radiobutton(len(self.roi_list)-1)
_venn2.py 文件源码 项目:johnson-county-ddj-public 作者: dssg 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def venn2_circles(subsets, normalize_to=1.0, alpha=1.0, color='black', linestyle='solid', linewidth=2.0, ax=None, **kwargs):
    '''
    Plots only the two circles for the corresponding Venn diagram.
    Useful for debugging or enhancing the basic venn diagram.
    parameters ``subsets``, ``normalize_to`` and ``ax`` are the same as in venn2()
    ``kwargs`` are passed as-is to matplotlib.patches.Circle.
    returns a list of three Circle patches.

    >>> c = venn2_circles((1, 2, 3))
    >>> c = venn2_circles({'10': 1, '01': 2, '11': 3}) # Same effect
    >>> c = venn2_circles([set([1,2,3,4]), set([2,3,4,5,6])]) # Also same effect
    '''
    if isinstance(subsets, dict):
        subsets = [subsets.get(t, 0) for t in ['10', '01', '11']]
    elif len(subsets) == 2:
        subsets = compute_venn2_subsets(*subsets)
    areas = compute_venn2_areas(subsets, normalize_to)
    centers, radii = solve_venn2_circles(areas)

    if ax is None:
        ax = gca()
    prepare_venn_axes(ax, centers, radii)
    result = []
    for (c, r) in zip(centers, radii):
        circle = Circle(c, r, alpha=alpha, edgecolor=color, facecolor='none', linestyle=linestyle, linewidth=linewidth, **kwargs)
        ax.add_patch(circle)
        result.append(circle)
    return result
plot_modifications.py 文件源码 项目:yt 作者: yt-project 项目源码 文件源码 阅读 31 收藏 0 点赞 0 评论 0
def __call__(self, plot):
        from matplotlib.patches import Circle

        if iterable(self.radius):
            self.radius = plot.data.ds.quan(self.radius[0], self.radius[1])
            self.radius = np.float64(self.radius.in_units(plot.xlim[0].units))

        # This assures the radius has the appropriate size in
        # the different coordinate systems, since one cannot simply
        # apply a different transform for a length in the same way
        # you can for a coordinate.
        if self.coord_system == 'data' or self.coord_system == 'plot':
            self.radius = self.radius * self.pixel_scale(plot)[0]
        else:
            self.radius /= (plot.xlim[1]-plot.xlim[0]).v

        x,y = self.sanitize_coord_system(plot, self.center,
                               coord_system=self.coord_system)

        cir = Circle((x, y), self.radius, transform=self.transform,
                     **self.circle_args)
        xx0, xx1 = plot._axes.get_xlim()
        yy0, yy1 = plot._axes.get_ylim()

        plot._axes.add_patch(cir)
        if self.text is not None:
            label = plot._axes.text(x, y, self.text, transform=self.transform,
                                    **self.text_args)
            self._set_font_properties(plot, [label], **self.text_args)

        plot._axes.set_xlim(xx0,xx1)
        plot._axes.set_ylim(yy0,yy1)
plot_panel.py 文件源码 项目:CAAPR 作者: Stargrazer82301 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def remove_overplot_on_image(self, msg=None):
        if self.primary_image_patch is not None:
            self.ztv_frame.primary_image_panel.axes.patches.remove(self.primary_image_patch)
        self.ztv_frame.primary_image_panel.figure.canvas.draw()
        self.primary_image_patch = None
        self.hideshow_button.SetLabel(u"Show")
ztv.py 文件源码 项目:CAAPR 作者: Stargrazer82301 项目源码 文件源码 阅读 30 收藏 0 点赞 0 评论 0
def on_button_release(self, event):
        if event.button == 1:  # left button
            if self.cursor_mode == 'Zoom':
                # this catches for the first click-release of a double-click
                if (time.time() - self.zoom_start_timestamp) > self.max_doubleclick_sec:
                    # this catches for a long click-and-release without motion
                    x0,y0 = self.zoom_rect.get_x(),self.zoom_rect.get_y()
                    x1 = x0 + self.zoom_rect.get_width()
                    y1 = y0 + self.zoom_rect.get_height()
                    if hasattr(event, 'xdata') and event.xdata is not None:
                        x1 = event.xdata
                    if hasattr(event, 'ydata') and event.ydata is not None:
                        y1 = event.ydata
                    if abs(x0 - x1) >= 2 and abs(y0 - y1) >= 2:
                        self.center = wx.RealPoint((x0 + x1)/2., (y0 + y1)/2.)
                        panel_size = self.canvas.GetSize()
                        x_zoom_factor = panel_size.x / abs(x1 - x0)
                        y_zoom_factor = panel_size.y / abs(y1 - y0)
                        self.ztv_frame.zoom_factor = min(x_zoom_factor, y_zoom_factor)
                        self.set_and_get_xy_limits()
                if self.zoom_rect in self.axes.patches:
                    self.axes.patches.remove(self.zoom_rect)
                self.zoom_rect = None
                self.figure.canvas.draw()
            else:
                if (self.available_cursor_modes.has_key(self.cursor_mode) and
                    self.available_cursor_modes[self.cursor_mode].has_key('on_button_release')):
                    self.available_cursor_modes[self.cursor_mode]['on_button_release'](event)
phot_panel.py 文件源码 项目:CAAPR 作者: Stargrazer82301 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def remove_overplot_on_image(self, *args):
        if self.star_center_patch is not None:
            self.ztv_frame.primary_image_panel.axes.patches.remove(self.star_center_patch)
            self.star_center_patch = None
        if self.star_aperture_patch is not None:
            self.ztv_frame.primary_image_panel.axes.patches.remove(self.star_aperture_patch)
            self.star_aperture_patch = None
        if self.sky_aperture_patch is not None:
            self.ztv_frame.primary_image_panel.axes.patches.remove(self.sky_aperture_patch)
            self.sky_aperture_patch = None
        self.ztv_frame.primary_image_panel.figure.canvas.draw()
        self.hideshow_button.SetLabel(u"Show")
plot_panel.py 文件源码 项目:CAAPR 作者: Stargrazer82301 项目源码 文件源码 阅读 34 收藏 0 点赞 0 评论 0
def remove_overplot_on_image(self, msg=None):
        if self.primary_image_patch is not None:
            self.ztv_frame.primary_image_panel.axes.patches.remove(self.primary_image_patch)
        self.ztv_frame.primary_image_panel.figure.canvas.draw()
        self.primary_image_patch = None
        self.hideshow_button.SetLabel(u"Show")
ztv.py 文件源码 项目:CAAPR 作者: Stargrazer82301 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def on_button_release(self, event):
        if event.button == 1:  # left button
            if self.cursor_mode == 'Zoom':
                # this catches for the first click-release of a double-click
                if (time.time() - self.zoom_start_timestamp) > self.max_doubleclick_sec:
                    # this catches for a long click-and-release without motion
                    x0,y0 = self.zoom_rect.get_x(),self.zoom_rect.get_y()
                    x1 = x0 + self.zoom_rect.get_width()
                    y1 = y0 + self.zoom_rect.get_height()
                    if hasattr(event, 'xdata') and event.xdata is not None:
                        x1 = event.xdata
                    if hasattr(event, 'ydata') and event.ydata is not None:
                        y1 = event.ydata
                    if abs(x0 - x1) >= 2 and abs(y0 - y1) >= 2:
                        self.center = wx.RealPoint((x0 + x1)/2., (y0 + y1)/2.)
                        panel_size = self.canvas.GetSize()
                        x_zoom_factor = panel_size.x / abs(x1 - x0)
                        y_zoom_factor = panel_size.y / abs(y1 - y0)
                        self.ztv_frame.zoom_factor = min(x_zoom_factor, y_zoom_factor)
                        self.set_and_get_xy_limits()
                if self.zoom_rect in self.axes.patches:
                    self.axes.patches.remove(self.zoom_rect)
                self.zoom_rect = None
                self.figure.canvas.draw()
            else:
                if (self.available_cursor_modes.has_key(self.cursor_mode) and
                    self.available_cursor_modes[self.cursor_mode].has_key('on_button_release')):
                    self.available_cursor_modes[self.cursor_mode]['on_button_release'](event)
phot_panel.py 文件源码 项目:CAAPR 作者: Stargrazer82301 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def remove_overplot_on_image(self, *args):
        if self.star_center_patch is not None:
            self.ztv_frame.primary_image_panel.axes.patches.remove(self.star_center_patch)
            self.star_center_patch = None
        if self.star_aperture_patch is not None:
            self.ztv_frame.primary_image_panel.axes.patches.remove(self.star_aperture_patch)
            self.star_aperture_patch = None
        if self.sky_aperture_patch is not None:
            self.ztv_frame.primary_image_panel.axes.patches.remove(self.sky_aperture_patch)
            self.sky_aperture_patch = None
        self.ztv_frame.primary_image_panel.figure.canvas.draw()
        self.hideshow_button.SetLabel(u"Show")
phot_panel.py 文件源码 项目:CAAPR 作者: Stargrazer82301 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def redraw_overplot_on_image(self, *args):
        if self.star_center_patch is not None:
            self.ztv_frame.primary_image_panel.axes.patches.remove(self.star_center_patch)
        if self.star_aperture_patch is not None:
            self.ztv_frame.primary_image_panel.axes.patches.remove(self.star_aperture_patch)
        if self.sky_aperture_patch is not None:
            self.ztv_frame.primary_image_panel.axes.patches.remove(self.sky_aperture_patch)
        self.star_center_patch = Circle([self.xcentroid, self.ycentroid], 0.125, color=self.aprad_color)
        self.ztv_frame.primary_image_panel.axes.add_patch(self.star_center_patch)
        self.star_aperture_patch = Circle([self.xcentroid, self.ycentroid], self.aprad, color=self.aprad_color, alpha=self.alpha)
        self.ztv_frame.primary_image_panel.axes.add_patch(self.star_aperture_patch)
        self.sky_aperture_patch = Wedge([self.xcentroid, self.ycentroid], self.skyradout, 0., 360., 
                                        width=self.skyradout - self.skyradin, color=self.skyrad_color, alpha=self.alpha)
        self.ztv_frame.primary_image_panel.axes.add_patch(self.sky_aperture_patch)
        self.ztv_frame.primary_image_panel.figure.canvas.draw()
        self.hideshow_button.SetLabel(u"Hide")
CellDrawing.py 文件源码 项目:Doc-Analysis-Public-Data 作者: AdnanMuhib 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def draw_prediction(self, arr, img, file_name):
        image = np.array(Image.open(img))
        fig, ax = plt.subplots(1)
        ax.imshow(image)
        for items in arr:
            # If it was predicted correctly table so green
            if (items.prediction == 1) and (items.table == 1):
                rect = patches.Rectangle((items.x, items.y),
                                     items.width, items.height,
                                     linewidth=1, edgecolor='g',
                                               facecolor='none')
                ax.add_patch(rect)
            # If it was predicted correctly non table so blue 
            elif(items.prediction == 0) and (items.table == 0):
                rect = patches.Rectangle((items.x, items.y),
                                     items.width, items.height,
                                     linewidth=1, edgecolor='b',
                                               facecolor='none')
                ax.add_patch(rect)
            # If it was predicted incorrectly table so red
            elif(items.prediction == 1) and (items.table == 0):
                rect = patches.Rectangle((items.x, items.y),
                                     items.width, items.height,
                                     linewidth=1, edgecolor='r',
                                               facecolor='none')
                ax.add_patch(rect)
            # If it was predicted incorrectly non-table so yellow
            elif(items.prediction == 0) and (items.table == 1):
                rect = patches.Rectangle((items.x, items.y),
                                     items.width, items.height,
                                     linewidth=1, edgecolor='y',
                                               facecolor='none')
                ax.add_patch(rect)
        plt.savefig(file_name + "_post_processor.png", transparent=True, dpi=300)
        plt.close()
        return

##############################################################################################
########################################END###################################################
##############################################################################################
test_graphics_others.py 文件源码 项目:PyDataLondon29-EmbarrassinglyParallelDAWithAWSLambda 作者: SignalMedia 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def test_hist_bins_legacy(self):
        df = DataFrame(np.random.randn(10, 2))
        ax = df.hist(bins=2)[0][0]
        self.assertEqual(len(ax.patches), 2)
test_graphics_others.py 文件源码 项目:PyDataLondon29-EmbarrassinglyParallelDAWithAWSLambda 作者: SignalMedia 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def test_radviz(self):
        from pandas.tools.plotting import radviz
        from matplotlib import cm

        df = self.iris
        _check_plot_works(radviz, frame=df, class_column='Name')

        rgba = ('#556270', '#4ECDC4', '#C7F464')
        ax = _check_plot_works(
            radviz, frame=df, class_column='Name', color=rgba)
        # skip Circle drawn as ticks
        patches = [p for p in ax.patches[:20] if p.get_label() != '']
        self._check_colors(
            patches[:10], facecolors=rgba, mapping=df['Name'][:10])

        cnames = ['dodgerblue', 'aquamarine', 'seagreen']
        _check_plot_works(radviz, frame=df, class_column='Name', color=cnames)
        patches = [p for p in ax.patches[:20] if p.get_label() != '']
        self._check_colors(patches, facecolors=cnames, mapping=df['Name'][:10])

        _check_plot_works(radviz, frame=df,
                          class_column='Name', colormap=cm.jet)
        cmaps = lmap(cm.jet, np.linspace(0, 1, df['Name'].nunique()))
        patches = [p for p in ax.patches[:20] if p.get_label() != '']
        self._check_colors(patches, facecolors=cmaps, mapping=df['Name'][:10])

        colors = [[0., 0., 1., 1.],
                  [0., 0.5, 1., 1.],
                  [1., 0., 0., 1.]]
        df = DataFrame({"A": [1, 2, 3],
                        "B": [2, 1, 3],
                        "C": [3, 2, 1],
                        "Name": ['b', 'g', 'r']})
        ax = radviz(df, 'Name', color=colors)
        handles, labels = ax.get_legend_handles_labels()
        self._check_colors(handles, facecolors=colors)
plotting.py 文件源码 项目:PyDataLondon29-EmbarrassinglyParallelDAWithAWSLambda 作者: SignalMedia 项目源码 文件源码 阅读 36 收藏 0 点赞 0 评论 0
def _add_legend_handle(self, handle, label, index=None):
        from matplotlib.patches import Rectangle
        # Because fill_between isn't supported in legend,
        # specifically add Rectangle handle here
        alpha = self.kwds.get('alpha', None)
        handle = Rectangle((0, 0), 1, 1, fc=handle.get_color(), alpha=alpha)
        LinePlot._add_legend_handle(self, handle, label, index=index)
pyTarget.py 文件源码 项目:pyMHT 作者: erikliland 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def _plotCovarianceEllipse(self, eta2):
        from matplotlib.patches import Ellipse
        lambda_, _ = np.linalg.eig(self.kalmanFilter.S)
        ell = Ellipse(xy=(self.kalmanFilter.x_bar[0], self.kalmanFilter.x_bar[1]),
                      width=np.sqrt(lambda_[0]) * np.sqrt(eta2) * 2,
                      height=np.sqrt(lambda_[1]) * np.sqrt(eta2) * 2,
                      angle=np.rad2deg(np.arctan2(lambda_[1], lambda_[0])),
                      linewidth=2,
                      )
        ell.set_facecolor('none')
        ell.set_linestyle("dotted")
        ell.set_alpha(0.5)
        ax = plt.subplot(111)
        ax.add_artist(ell)
test_aux.py 文件源码 项目:tf-Faster-RCNN 作者: kevinjliang 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def _plot_patch(ax, bbox, prob, class_name, color):
    """ Plot a rectangle (labeled with color, class_name, and prob) on the test image """

    # Calculate Bounding Box Rectangle and plot it
    height = bbox[3] - bbox[1]
    width = bbox[2] - bbox[0]
    rect = patches.Rectangle((bbox[0], bbox[1]), width, height, linewidth=2, edgecolor=color, facecolor='none')
    ax.add_patch(rect)

    # Add confidence prob and class text to box
    if prob is not None:
        ax.text(bbox[0], bbox[1] - 2,
                '{:s} {:.3f}'.format(class_name, prob),
                bbox=dict(facecolor=color, alpha=0.5),
                fontsize=8, color='white')
faster_rcnn_conv5.py 文件源码 项目:tf-Faster-RCNN 作者: kevinjliang 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def plot_patch(ax, patches, bbox, gt):
        if gt is True:
            color = 'g'
        else:
            color = 'r'
        # Calculate Bounding Box Rectangle and plot it
        width = bbox[3] - bbox[1]
        height = bbox[2] - bbox[0]
        rect = patches.Rectangle((bbox[1], bbox[0]), height, width, linewidth=2, edgecolor=color, facecolor='none')
        ax.add_patch(rect)


问题


面经


文章

微信
公众号

扫码关注公众号