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


Python Rectangle.set_ec方法代码示例

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


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

示例1: draw

# 需要导入模块: from matplotlib.patches import Rectangle [as 别名]
# 或者: from matplotlib.patches.Rectangle import set_ec [as 别名]
 def draw(self):
 
   dpi = self.prefs['dpi']
   ax_xsize = self.ax.get_window_extent().width
   ax_ysize = self.ax.get_window_extent().height  
   nLabels = len(self.labels)
   nColumns = min(self.prefs['legend_max_columns'],int(ax_xsize/self.column_width))
   
   maxRows = self.prefs['legend_max_rows']
   nRows_ax = int(ax_ysize/1.6/self.prefs['text_size'])
   nRows_label = nLabels/nColumns + (nLabels%nColumns != 0)
   nRows = max(1,min(min(nRows_label,maxRows),nRows_ax ))
   maxLabels = nColumns*nRows - 1
   self.ax.set_xlim(0.,float(ax_xsize))
   self.ax.set_ylim(-float(ax_ysize),0.)
  
   legend_text_size,legend_text_padding = self.__get_legend_text_size()
   legend_text_size_point = pixelToPoint(legend_text_size,dpi)
       
   box_width = legend_text_size
   legend_offset = (ax_xsize - nColumns*self.column_width)/2 
   
   nc = 0
   #self.labels.reverse()
   
   for label,num in self.labels:
     num_flag = self.prefs.get('legend_numbers',True)
     percent_flag = self.prefs.get('legend_unit','')
     if num_flag:
       if percent_flag == "%":
         num = "%.1f" % num +'%'
       else:  
         num = "%.1f" % num
     else:
       num = None  
     color = self.palette.getColor(label)
     row = nc%nRows 
     column = nc/nRows          
     if row == nRows-1 and column == nColumns-1 and nc != nLabels-1:
       last_text = '... plus %d more' % (nLabels-nc)
       self.ax.text(float(column*self.column_width)+legend_offset,-float(row*1.6*box_width),
                    last_text,horizontalalignment='left',
                    verticalalignment='top',size=legend_text_size_point)  
       break   
     else:
       self.ax.text(float(column*self.column_width)+2.*box_width+legend_offset,-row*1.6*box_width,
                    str(label),horizontalalignment='left',
                    verticalalignment='top',size=legend_text_size_point)
       if num is not None:
         self.ax.text(float((column+1)*self.column_width)-2*box_width+legend_offset,-float(row*1.6*box_width),
                      str(num),horizontalalignment='right',
                      verticalalignment='top',size=legend_text_size_point)             
       box = Rectangle((float(column*self.column_width)+legend_offset,-float(row*1.6*box_width)-box_width),
                       box_width,box_width)            
       box.set_ec('black')
       box.set_linewidth(pixelToPoint(0.5,dpi))
       box.set_fc(color)
       self.ax.add_patch(box)
       nc += 1    
开发者ID:DIRACGrid-test,项目名称:DIRAC,代码行数:61,代码来源:Legend.py


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