Changeset 32548

Show
Ignore:
Timestamp:
04/18/09 01:27:01 (4 years ago)
Author:
rezoo
Message:

verificator.py add plotIndications()

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • lang/python/tremolo/tremolo/verificator.py

    r32449 r32548  
    146146                        p_list.append(float(n) / float(N)) 
    147147                return p_list 
     148         
     149        def plotIndications(self, keys, start, end, main=-1, 
     150                            margin=(0.1, 0.1, 0.1, 0.1)): 
     151                """ 
     152                指定された指標群のプロットを行います. 
     153                 
     154                keys   : プロットする指標のリスト 
     155                start  : tの開始範囲 
     156                end    : tの終了範囲 
     157                main   : 大きく表示させたい指標のインデックス.-1ならば等間隔に設定 
     158                margin : 余白の設定.top,right,bottom,leftの順に設定. 
     159                         指定されない場合はすべてが10%の余白をとる 
     160                """ 
     161                from pylab import axes 
     162                from matplotlib.ticker import NullFormatter 
     163                indication_list = [self.indications[key]["indication"] for key in keys] 
     164                 
     165                width  = 1.0 - margin[1] - margin[3] 
     166                height = 1.0 - margin[0] - margin[2] 
     167                 
     168                index_length = main > -1 and len(keys)+1 or len(keys) 
     169                axes_h = height/float(index_length) 
     170                 
     171                p = margin[2] 
     172                axes_list = [] 
     173                nullfmt = NullFormatter() 
     174                for i in xrange(len(keys)): 
     175                        if i == main: 
     176                                a = axes([margin[3], p, width, axes_h*2.0]) 
     177                                a.xaxis.set_major_formatter(nullfmt) 
     178                                axes_list.append(a) 
     179                                p += p + axes_h*2.0 
     180                        else: 
     181                                a = axes([margin[3], p, width, axes_h]) 
     182                                a.xaxis.set_major_formatter(nullfmt) 
     183                                axes_list.append(a) 
     184                                p += axes_h 
     185                 
     186                for (ind, ax) in zip(indication_list, axes_list): 
     187                        ind.plot(start, end, axes=ax) 
     188