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


Python Rectangle.set_clip_on方法代码示例

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


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

示例1: highlight_artist

# 需要导入模块: from matplotlib.patches import Rectangle [as 别名]
# 或者: from matplotlib.patches.Rectangle import set_clip_on [as 别名]
    def highlight_artist(self, val, artist=None):
#        print val, artist
        figure=self.get_figpage()._artists[0]
        ax = self.get_figaxes()
        if artist is None:
           alist=self._artists
        else:
           alist=artist 
        if val == True:
           container = self.get_container()
           if container is None: return
           
           de = self.get_data_extent()
           from ifigure.matplotlib_mod.art3d_gl import AxesImageGL
           if isinstance(alist[0], AxesImageGL):
               hl = alist[0].add_hl_mask()
               for item in hl:
                   alist[0].figobj_hl.append(item)
                
#               hl = alist[0].make_hl_artist(container)
#               rect_alpha = 0.0                   
           else:
               x=[de[0],de[1],de[1],de[0],de[0]]
               y=[de[2],de[2],de[3],de[3],de[2]]               
               hl= container.plot(x, y, marker='s', 
                                 color='k', linestyle='None',
                                 markerfacecolor='None',
                                 markeredgewidth = 0.5,                                  
                                 scalex=False, scaley=False)
               rect_alpha = 0.3
           
               
               hlp = Rectangle((de[0],de[2]),
                                de[1]-de[0],
                                de[3]-de[2],
                                alpha=rect_alpha, facecolor='k',
                                figure = figure, 
                                transform= container.transData)
               if ax is not None:
                  x0, y0 = ax._artists[0].transAxes.transform((0,0))
                  x1, y1 = ax._artists[0].transAxes.transform((1,1))
                  bbox = Bbox([[x0,y0],[x1,y1]])
                  hlp.set_clip_box(bbox)
                  hlp.set_clip_on(True)

               figure.patches.append(hlp)
               for item in (hl[0], hlp):
                   alist[0].figobj_hl.append(item)
        else:
           for a in alist:
              if len(a.figobj_hl) != 0:
                 a.figobj_hl[0].remove()
                 figure.patches.remove(a.figobj_hl[1])
              a.figobj_hl=[]
开发者ID:piScope,项目名称:piScope,代码行数:56,代码来源:fig_image.py

示例2: highlight_artist

# 需要导入模块: from matplotlib.patches import Rectangle [as 别名]
# 或者: from matplotlib.patches.Rectangle import set_clip_on [as 别名]
    def highlight_artist(self, val, artist=None):
        figure=self.get_figpage()._artists[0]
        ax = self.get_figaxes()
        if val:
           if len(self._artists[0].figobj_hl) != 0: return
           box = self.get_artist_extent_all()
           self._artist_extent = box
           if box[0] is None: return
           x = [box[0], box[0], box[1], box[1], box[0]]
           y = [box[3], box[2], box[2], box[3], box[3]]

           hl= Line2D(x, y, marker='s', 
                                 color='k', linestyle='None',
                                 markerfacecolor='k',
                                 markeredgewidth =  0.5,                      
                                 figure=figure, alpha=0.3)
           figure.lines.append(hl)
           xy = (box[0], box[2])
           w = box[1] - box[0]
           h = box[3] - box[2]
           hlp = Rectangle(xy, w, h, alpha=0.3, facecolor='k',
                     figure = figure)
           if ax is not None:
              x0, y0 = ax._artists[0].transAxes.transform((0,0))
              x1, y1 = ax._artists[0].transAxes.transform((1,1))
              bbox = Bbox([[x0,y0],[x1,y1]])
              hlp.set_clip_box(bbox)
              hlp.set_clip_on(True)
           figure.patches.append(hlp)
#           if ax is not None and ax.get_3d():
#               import mpl_toolkits.mplot3d.art3d as art3d
#               art3d.patch_2d_to_3d(hl)
#               if len(ax._artists) != 0:
#                   a.axes = self.get_figaxes()._artists[0]
           self._artists[0].figobj_hl.extend([hl, hlp])
        else:
           if len(self._artists[0].figobj_hl) == 2:
              figure.lines.remove(self._artists[0].figobj_hl[0])
              figure.patches.remove(self._artists[0].figobj_hl[1])
           self._artists[0].figobj_hl = []
开发者ID:piScope,项目名称:piScope,代码行数:42,代码来源:fig_grp.py

示例3: modelMap

# 需要导入模块: from matplotlib.patches import Rectangle [as 别名]
# 或者: from matplotlib.patches.Rectangle import set_clip_on [as 别名]

#.........这里部分代码省略.........
                    cxis, cyis = m(ctlons, ctlats)
                for ctlat, ctlon, cxi, cyi, name in zip(ctlats, ctlons, cxis, cyis, names):
                    m.scatter(ctlon, ctlat, c='k', latlon=True, marker='.',
                              zorder=100000)
                    ax.text(cxi, cyi, name, fontname=fontname,
                            fontsize=fontsize, zorder=100000)
            except Exception as e:
                print('Failed to plot cities, %s' % e)

        #draw star at epicenter
        plt.sca(ax)
        if edict is not None:
            elat, elon = edict['lat'], edict['lon']
            ex, ey = m(elon, elat)
            plt.plot(ex, ey, '*', markeredgecolor='k', mfc='None', mew=1.0,
                     ms=15, zorder=10000.)

        m.drawmapboundary(fill_color=watercolor)

        m.fillcontinents(color=clear_color, lake_color=watercolor)
        m.drawrivers(color=watercolor)
        ##m.drawcoastlines()

        #draw country boundaries
        m.drawcountries(color=countrycolor, linewidth=1.0)

        #add map scale
        m.drawmapscale((bxmax+bxmin)/2., (bymin+(bymax-bymin)/9.), clon, clat, np.round((((bxmax-bxmin)*111)/5)/10.)*10, barstyle='fancy', zorder=10)

        # Add border
        autoAxis = ax.axis()
        rec = Rectangle((autoAxis[0]-0.7, autoAxis[2]-0.2), (autoAxis[1]-autoAxis[0])+1, (autoAxis[3]-autoAxis[2])+0.4, fill=False, lw=1, zorder=1e8)
        rec = ax.add_patch(rec)
        rec.set_clip_on(False)

        plt.draw()

        if sref is not None:
            label2 = '%s\nsource: %s' % (label1, sref)  # '%s\n' % label1 + r'{\fontsize{10pt}{3em}\selectfont{}%s}' % sref  #
        else:
            label2 = label1
        plt.title(label2, axes=ax, fontsize=fontsizesub)

        #draw scenario watermark, if scenario
        if isScenario:
            plt.sca(ax)
            cx, cy = m(clon, clat)
            plt.text(cx, cy, 'SCENARIO', rotation=45, alpha=0.10, size=72, ha='center', va='center', color='red')

        #if ds: # Could add this to print "downsampled" on map
        #    plt.text()

        if k == 1 and rowpan == 1:
            # adjust single level plot
            axsize = ax.get_window_extent().transformed(fig.dpi_scale_trans.inverted())
            ht2 = axsize.height
            fig.set_figheight(ht2*1.6)
        else:
            plt.tight_layout()

        # Make room for suptitle - tight layout doesn't account for it
        plt.subplots_adjust(top=0.92)

    if printparam is True:
        try:
            fig = plt.gcf()
开发者ID:usgs,项目名称:groundfailure,代码行数:70,代码来源:makemaps.py

示例4: highlight_artist

# 需要导入模块: from matplotlib.patches import Rectangle [as 别名]
# 或者: from matplotlib.patches.Rectangle import set_clip_on [as 别名]
    def highlight_artist(self, val, artist=None):
        from ifigure.matplotlib_mod.art3d_gl import Poly3DCollectionGL
        from ifigure.matplotlib_mod.art3d_gl import Line3DCollectionGL        
        figure=self.get_figpage()._artists[0]
        ax = self.get_figaxes()
        if artist is None:
           alist=self._artists
        else:
           alist=artist 

        if val == True:
           if self._parent is None: return
           container = self.get_container()
           if container is None: return

           if isinstance(alist[0], Poly3DCollectionGL):
               hl = alist[0].add_hl_mask()               
               for item in hl:
                   alist[0].figobj_hl.append(item)
           else:          
               de = self.get_data_extent()
               x=(de[0], de[1],de[1],de[0],de[0])
               y=(de[2], de[2],de[3],de[3],de[2])

               facecolor='k'
               if isinstance(alist[0], Poly3DCollectionGL):
                   hl = alist[0].make_hl_artist(container)
                   facecolor = 'none'
                   self._hit_path = None               
               elif isinstance(alist[0], Line3DCollectionGL):
                   hl = alist[0].make_hl_artist(container)
                   facecolor = 'none'
                   self._hit_path = None
               else:
                   hl= container.plot(x, y, marker='s', 
                                     color='k', linestyle='None',
                                     markerfacecolor='None',
                                     markeredgewidth =  0.5,                                  
                                     scalex=False, scaley=False)
               for item in hl:
                  alist[0].figobj_hl.append(item)


               if self._hit_path is not None:
                  v = self._hit_path.vertices
                  hl= container.plot(v[:,0], v[:,1], marker='s', 
                                     color='k', linestyle='None',
                                     markerfacecolor='None',
                                     markeredgewidth =  0.5,  
                                     scalex=False, scaley=False)
                  for item in hl:
                     alist[0].figobj_hl.append(item)

               hlp = Rectangle((de[0],de[2]),
                                de[1]-de[0],
                                de[3]-de[2],
                                alpha=0.3, facecolor=facecolor,
                                figure = figure, 
                                transform= container.transData)
               if ax is not None:
                  x0, y0 = ax._artists[0].transAxes.transform((0,0))
                  x1, y1 = ax._artists[0].transAxes.transform((1,1))
                  bbox = Bbox([[x0,y0],[x1,y1]])
                  hlp.set_clip_box(bbox)
                  hlp.set_clip_on(True)
               figure.patches.append(hlp)
               alist[0].figobj_hl.append(hlp)
        else:
           for a in alist:
              if len(a.figobj_hl) == 0: continue
              for hl in a.figobj_hl[:-1]:
                 hl.remove()
              if isinstance(alist[0], Poly3DCollectionGL):
                 a.figobj_hl[-1].remove()
              else:
                  figure.patches.remove(a.figobj_hl[-1])
              a.figobj_hl=[]
开发者ID:piScope,项目名称:piScope,代码行数:79,代码来源:fig_contour.py

示例5: create_design_plot

# 需要导入模块: from matplotlib.patches import Rectangle [as 别名]
# 或者: from matplotlib.patches.Rectangle import set_clip_on [as 别名]
    def create_design_plot(self):
        """Creates a RNAi design plot."""

        # Temp file for storing
        temp_img_file = tempfile.mkstemp()

        # Create main figure
        fig, ax1 = plt.subplots(figsize=(15, 4))

        off_target_dict, main_target_dict, efficient_dict, main_hits_histo = general_helpers.get_target_data(self.f_in, self.sirna_size)

        # If there are no hits, we show only the efficient sirnas for designing a construct
        if self.main_targets == []:
            off_target_dict = {}
            main_target_dict = {}
            main_hits_histo = []

        # Off-target position list
        off_targets_pos = set()
        for i in off_target_dict.values():
            off_targets_pos = off_targets_pos | i

        # Main-target position list
        main_targets_plot = set()
        for i in main_target_dict.values():
            main_targets_plot = main_targets_plot | i

        # Efficient position list
        eff_sirna_plot = []
        for i in efficient_dict.values():
            eff_sirna_plot.extend(i)
        eff_sirna_plot.sort()

        # Draw efficiency plot
        eff_sirna_histo = np.bincount(eff_sirna_plot, minlength=self.query_length)
        ax1.plot(eff_sirna_histo, 'r-', label='Efficient siRNA hits')

        # Draw main target histogram
        main_histo = np.bincount(main_hits_histo, minlength=self.query_length)
        ax1.plot(main_histo, 'b-', label='Main target siRNA hits')

        # Draw main targets as green rectangles inside plot figure
        for region in main_targets_plot:
            someX, someY = region, 0.
            currentAxis = fig.gca()
            tri1 = Rectangle((someX, someY), 1, self.sirna_size + 3, color='g', alpha=0.2)#, label='green')
            currentAxis.add_patch(tri1)
            tri1.set_clip_on(False)
        
        # Draw off-targets as red rectangles inside plot figure
        for off_target in off_targets_pos:
            someX, someY = off_target, 0.
            currentAxis = fig.gca()
            tri2 = Rectangle((someX, someY), 1, self.sirna_size + 3, color='r', alpha=0.2)#, label='red')
            currentAxis.add_patch(tri2)
            tri2.set_clip_on(False)

        if max(eff_sirna_histo) > self.sirna_size:
            max_y = max(eff_sirna_histo) + 3
        else:
            max_y = self.sirna_size + 3

        ax1.set_ylim([0, max_y])
        x_text = 'mRNA sequence position\n\n'
        ax1.set_xlabel(x_text, fontsize=12)
        ax1.xaxis.set_ticks(np.arange(0, self.query_length, 50))
        ax1.set_ylabel('Nr of siRNAs', color='b', fontsize=12)
        ax1.set_xlim([0, self.query_length])
        plt.title("RNAi design plot\n\n", fontsize=14)
        plt.tight_layout()
        p1 = Rectangle((0, 0), 1, 1, fc="g", alpha=0.2)
        p2 = Rectangle((0, 0), 1, 1, fc="r", alpha=0.2)
        p3 = mlines.Line2D([], [], color='r')
        p4 = mlines.Line2D([], [], color='b')
        plt.legend([p1,p2, p3, p4], ["Main target", "Off target", 'Efficient siRNAs', 'All siRNAs'],
                    bbox_to_anchor=(0., 1.02, 1., .102), loc=4, ncol=4, mode="", borderaxespad=0.5, frameon=True)
        plt.savefig(temp_img_file[1] + '.png')

        #plt.show()
        plt.close(fig)
        return temp_img_file[1] + '.png', off_target_dict, main_target_dict
开发者ID:snowformatics,项目名称:siFi21,代码行数:83,代码来源:create_plots.py


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