tools/plot-values/scatter.py
branchdev
changeset 244 66235db8d8b7
parent 13896030f8d2f2c
       1 --- a/tools/plot-values/scatter.py	Thu Jul 09 02:42:47 2009 -0700
       2 +++ b/tools/plot-values/scatter.py	Mon Jul 25 23:21:29 2011 -0700
       3 @@ -6,7 +6,7 @@
       4  import  os.path         as     osp
       5  
       6  
       7 -def plot(val1_fn, val2_fn):
       8 +def plot(val1_fn, val2_fn, outfn = None):
       9      values1 = []
      10      with open(val1_fn) as fp:
      11          for line in fp.xreadlines():
      12 @@ -21,15 +21,23 @@
      13      values2 = [v % 1. for v in values2]
      14      print min(values1), max(values2), min(values1), min(values2)
      15  
      16 -    scatter(values1, values2)
      17 +    scatter(values1, values2, s=10)
      18      axes().set_aspect('equal')
      19 -    show()
      20 +    if not outfn:
      21 +        show()
      22 +    else:
      23 +        savefig(outfn)
      24  
      25  if __name__ == '__main__':
      26      if len(argv) < 3:
      27 -        print "Usage: %s VALUES1 VALUES2" % argv[0]
      28 +        print "Usage: %s VALUES1 VALUES2 [OUTPUT]" % argv[0]
      29          exit()
      30  
      31      val1_fn = argv[1]
      32      val2_fn  = argv[2]
      33 -    plot(val1_fn, val2_fn)
      34 +    
      35 +    outfn = None
      36 +    if len(argv) > 3: 
      37 +        outfn = argv[3]
      38 +
      39 +    plot(val1_fn, val2_fn, outfn)