Fixed plot.py in tools/plot-values dev
authorDmitriy Morozov <dmitriy@mrzv.org>
Thu Jul 09 07:47:22 2009 -0700 (2009-07-09)
branchdev
changeset 141cda0b85ffc50
parent 140 9851fee5a33b
child 142 ae2b1702c936
Fixed plot.py in tools/plot-values
tools/plot-values/plot.py
tools/plot-values/scatter.py
     1.1 --- a/tools/plot-values/plot.py	Thu May 14 17:43:19 2009 -0700
     1.2 +++ b/tools/plot-values/plot.py	Thu Jul 09 07:47:22 2009 -0700
     1.3 @@ -27,18 +27,17 @@
     1.4      values = [(v-m) % 1. for v in values]
     1.5      print "V:", min(values), max(values)
     1.6  
     1.7 -    aspect = (max(yy) - min(yy))/(max(xx) - min(xx)) + .1
     1.8 -    # aspect = .5
     1.9 -
    1.10      # hsv()
    1.11 -    # fig = figure(figsize = (3,3*aspect))
    1.12 +    fig = figure()
    1.13 +    scatter(xx,yy,s=10,c=values)
    1.14 +    colorbar()
    1.15 +    
    1.16      # ax = fig.add_axes([-.05,-.1,1.1,1.1])
    1.17      ax = axes()
    1.18      ax.set_axis_off()
    1.19      ax.set_aspect('equal', 'box')
    1.20 -    ax.scatter(xx,yy,s=10,c=values)
    1.21      # adjust(0,0,1,1,0,0)
    1.22 -    colorbar()
    1.23 +
    1.24      fig.savefig(output_fn)
    1.25  
    1.26  if __name__ == '__main__':
     2.1 --- a/tools/plot-values/scatter.py	Thu May 14 17:43:19 2009 -0700
     2.2 +++ b/tools/plot-values/scatter.py	Thu Jul 09 07:47:22 2009 -0700
     2.3 @@ -6,7 +6,7 @@
     2.4  import  os.path         as     osp
     2.5  
     2.6  
     2.7 -def plot(val1_fn, val2_fn):
     2.8 +def plot(val1_fn, val2_fn, outfn = None):
     2.9      values1 = []
    2.10      with open(val1_fn) as fp:
    2.11          for line in fp.xreadlines():
    2.12 @@ -21,15 +21,23 @@
    2.13      values2 = [v % 1. for v in values2]
    2.14      print min(values1), max(values2), min(values1), min(values2)
    2.15  
    2.16 -    scatter(values1, values2)
    2.17 +    scatter(values1, values2, s=10)
    2.18      axes().set_aspect('equal')
    2.19 -    show()
    2.20 +    if not outfn:
    2.21 +        show()
    2.22 +    else:
    2.23 +        savefig(outfn)
    2.24  
    2.25  if __name__ == '__main__':
    2.26      if len(argv) < 3:
    2.27 -        print "Usage: %s VALUES1 VALUES2" % argv[0]
    2.28 +        print "Usage: %s VALUES1 VALUES2 [OUTPUT]" % argv[0]
    2.29          exit()
    2.30  
    2.31      val1_fn = argv[1]
    2.32      val2_fn  = argv[2]
    2.33 -    plot(val1_fn, val2_fn)
    2.34 +    
    2.35 +    outfn = None
    2.36 +    if len(argv) > 3: 
    2.37 +        outfn = argv[3]
    2.38 +
    2.39 +    plot(val1_fn, val2_fn, outfn)