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


Python Rectangle.set_fill方法代码示例

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


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

示例1: get_gate_patch

# 需要导入模块: from matplotlib.patches import Rectangle [as 别名]
# 或者: from matplotlib.patches.Rectangle import set_fill [as 别名]
    def get_gate_patch(self):
        '''Returns a matplotlib patch to be drawn on the canvas whose dimensions
        have been computed from the current gate.
        '''
        x_min, x_max = self.subplot.get_xlim()
        x_range = x_max - x_min
        y_min, y_max = self.subplot.get_ylim()
        y_range = y_max - y_min
        
        for subgate in self.gate.get_subgates():       
            col = subgate.get_column()
            if col == self.x_column:
                x_min = subgate.get_min()
                x_range = subgate.get_max() - subgate.get_min()
            if col == self.y_column:
                y_min = subgate.get_min()
                y_range = subgate.get_max() - subgate.get_min()

        if self.patch not in self.subplot.patches:
            rect = Rectangle((x_min, y_min), x_range, y_range, animated=True)
            rect.set_fill(False)
            rect.set_linestyle('dashed')
            self.patch = self.subplot.add_patch(rect)
        else:
            self.patch.set_bounds(x_min, y_min, x_range, y_range)
        return self.patch
开发者ID:CellProfiler,项目名称:CellProfiler-Analyst,代码行数:28,代码来源:gating.py

示例2: IMaGE

# 需要导入模块: from matplotlib.patches import Rectangle [as 别名]
# 或者: from matplotlib.patches.Rectangle import set_fill [as 别名]
class IMaGE(object):
    def __init__(self,fit = False):
        self.ax = plt.gca()
        self.rect = Rectangle((0,0), 1, 1,antialiased = True,color = 'b',
							linestyle = 'solid', lw = 1.2)
        self.rect.set_fill(False)
        self.x0 = None
        self.y0 = None
        self.x1 = None
        self.y1 = None
        self.fit = fit

        self.key = False
        self.count = 0

        self.ax.add_patch(self.rect)
        self.ax.figure.canvas.mpl_connect('button_press_event', self.on_press)
        self.ax.figure.canvas.mpl_connect('motion_notify_event', self.on_motion)

    def on_press(self, event):
        self.count += 1
        self.key = True if self.key % 2 == 0 else False

        if self.key % 2 == 0:
            self.x = range(int(self.x0),int(self.x1))
            self.cut(im,x0 = self.x0,y0 = self.y0,x1 = self.x1,y1 = self.y1)
            self.ESF()
            self.LSF()
            self.MTF()

        self.x0 = event.xdata
        self.y0 = event.ydata

    def on_motion(self,event):
        if self.key:
            self.x1 = event.xdata
            self.y1 = event.ydata
            self.rect.set_width(self.x1 - self.x0)
            self.rect.set_height(self.y1 - self.y0)
            self.rect.set_xy((self.x0, self.y0))
            self.ax.figure.canvas.draw()

    def cut(self,image,**args):
        for i in args.keys():
            print "{} : {}".format(i,args[i])

        M = image[int(args["y0"]):int(args["y1"]),int(args["x0"]):int(args["x1"])]
        self.M_out = 0.299*M[:,:,0] + 0.589*M[:,:,1]+0.114*M[:,:,2]
        
        # plt.figure()
        # plt.title("operator box-area")
        # plt.imshow(self.M_out)
        # name = "box_selection_{}.png".format(self.count)
        # imag = Image.fromarray(np.asarray(self.M_out),mode = "RGB")
        # imag.save("prueba.png")
        # plt.show()

    def ESF(self):
        """
        Edge Spread Function calculation
        """

        self.X = self.M_out[100,:]
        mu = np.sum(self.X)/self.X.shape[0]
        tmp = (self.X[:] - mu)**2
        sigma = np.sqrt(np.sum(tmp)/self.X.shape[0])
        self.edge_function = (self.X[:] - mu)/sigma
        
        self.edge_function = self.edge_function[::3]
        x = range(0,self.edge_function.shape[0])

        plt.figure()
        plt.title(r'ESF')
        plt.plot(x,self.edge_function,'-ob')
        plt.show()

    def LSF(self):
        """
        Line Spread Function calculation
        """
        self.lsf = self.edge_function[:-2] - self.edge_function[2:]
        x = range(0,self.lsf.shape[0])
        
        # plt.figure()
        # plt.title("LSF")
        # plt.xlabel(r'pixel') ; plt.ylabel('intensidad')
        # plt.plot(x,self.lsf,'-or')
        # plt.show()

    def MTF(self):
        """
        Modulation Transfer Function calculation
        """
        self.mtf = abs(np.fft.fft(self.lsf))
        self.mtf = self.mtf[:]/np.max(self.mtf)
        self.mtf = self.mtf[:len(self.mtf)//2]
        ix = np.arange(self.mtf.shape[0]) / (self.mtf.shape[0])
        mtf_poly =  np.polyfit(ix, self.mtf, 6)
        poly = np.poly1d(mtf_poly)
        
#.........这里部分代码省略.........
开发者ID:alfagalileo,项目名称:py_mtf,代码行数:103,代码来源:mtf.py

示例3: draw_chiprep2

# 需要导入模块: from matplotlib.patches import Rectangle [as 别名]
# 或者: from matplotlib.patches.Rectangle import set_fill [as 别名]
    def draw_chiprep2(
        dm,
        cx,
        axi=0,
        fsel=None,
        in_image_bit=False,
        axi_color=0,
        bbox_bit=None,
        ell_alpha=None,
        ell_bit=None,
        xy_bit=None,
        color=None,
        qcm=None,
        **kwargs
    ):
        """
        Draws a chip representation over an already drawn chip
        cx           - the chiprep to draw. Managed by the chip manager
        axi          - the axis index to draw it in
        #TODO: in_image_bit becomes data_coordinates
        in_image_bit - are the data coordinates image or rotated chip? 
                       raw the chip by itself or in its original image
        axi_color    - use the color associated with axis index 
                       (used for ploting queries)
        ---
        Others are preference overloads
        bbox_bit - 
        ell_alpha
        ell_bit 
        xy_bit
        ell_color
        """
        # Allows display of cross database queries
        cm = dm.hs.cm if qcm is None else qcm
        # Grab Preferences
        xy_bit = dm.draw_prefs.points_bit if xy_bit is None else xy_bit
        ell_bit = dm.draw_prefs.ellipse_bit if ell_bit is None else ell_bit
        bbox_bit = dm.draw_prefs.bbox_bit if bbox_bit is None else bbox_bit
        ell_alpha = dm.draw_prefs.ellipse_alpha if ell_alpha is None else ell_alpha

        # Make sure alpha in range [0,1]
        if ell_alpha > 1:
            ell_alpha = 1.0
        if ell_alpha < 0:
            ell_alpha = 0.0

        # Get color from colormap or overloaded parameter
        if color is None:
            color = plt.get_cmap("hsv")(float(axi_color) / len(dm.ax_list))[0:3]
            if axi_color == 0:
                color = [color[0], color[1] + 0.5, color[2]]

        # Axis We are drawing to.
        ax = dm.ax_list[axi]
        T_data = ax.transData  # data coordinates -> display coordinates
        # Data coordinates are chip coords

        if xy_bit or ell_bit or fsel != None:
            T_fpts = T_data if not in_image_bit else Affine2D(cm.cx2_T_chip2img(cx)) + T_data
            fpts = cm.get_fpts(cx)
            if fsel is None:
                fsel = range(len(fpts))
            # ---DEVHACK---
            # Randomly sample the keypoints. (Except be sneaky)
            elif fsel == "rand":
                # Get Relative Position
                minxy = fpts.min(0)[0:2]
                maxxy = fpts.max(0)[0:2]
                rel_pos = (fpts[:, 0] - minxy[0]) / (maxxy[0] - minxy[0])
                to_zero = 1 - np.abs(rel_pos - 0.5) / 0.5
                pdf = to_zero / to_zero.sum()
                # Transform Relative Position to Probabilities
                # making it more likely to pick a centerpoint
                fsel = np.random.choice(xrange(len(fpts)), size=88, replace=False, p=pdf)
            # ---/DEVHACK---
            # Plot ellipses
            if ell_bit and len(fpts) > 0 and len(fsel) > 0:
                ells = dm._get_fpt_ell_collection(fpts[fsel, :], T_fpts, ell_alpha, color)
                ax.add_collection(ells)
            # Plot xy points
            if xy_bit and len(fpts) > 0 and len(fsel) > 0:
                ax.plot(
                    fpts[fsel, 0],
                    fpts[fsel, 1],
                    "o",
                    markeredgecolor=color,
                    markerfacecolor=color,
                    transform=T_fpts,
                    markersize=2,
                )
        # ===
        if bbox_bit:
            # Draw Bounding Rectangle in Image Coords
            [rx, ry, rw, rh] = cm.cx2_roi[cx]
            rxy = (rx, ry)
            # Convert to Chip Coords if needbe
            T_bbox = T_data if in_image_bit else Affine2D(np.linalg.inv(cm.cx2_T_chip2img(cx))) + T_data
            bbox = Rectangle(rxy, rw, rh, transform=T_bbox)
            # Visual Properties
            bbox.set_fill(False)
#.........这里部分代码省略.........
开发者ID:Erotemic,项目名称:hotspotter,代码行数:103,代码来源:DrawManager.py


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