Fixed plot.py in tools/plot-values dev
authorDmitriy Morozov <dmitriy@mrzv.org>
Thu, 09 Jul 2009 07:47:22 -0700
branchdev
changeset 141 cda0b85ffc50
parent 140 9851fee5a33b
child 142 ae2b1702c936
Fixed plot.py in tools/plot-values
tools/plot-values/plot.py
tools/plot-values/scatter.py
--- a/tools/plot-values/plot.py	Thu May 14 17:43:19 2009 -0700
+++ b/tools/plot-values/plot.py	Thu Jul 09 07:47:22 2009 -0700
@@ -27,18 +27,17 @@
     values = [(v-m) % 1. for v in values]
     print "V:", min(values), max(values)
 
-    aspect = (max(yy) - min(yy))/(max(xx) - min(xx)) + .1
-    # aspect = .5
-
     # hsv()
-    # fig = figure(figsize = (3,3*aspect))
+    fig = figure()
+    scatter(xx,yy,s=10,c=values)
+    colorbar()
+    
     # ax = fig.add_axes([-.05,-.1,1.1,1.1])
     ax = axes()
     ax.set_axis_off()
     ax.set_aspect('equal', 'box')
-    ax.scatter(xx,yy,s=10,c=values)
     # adjust(0,0,1,1,0,0)
-    colorbar()
+
     fig.savefig(output_fn)
 
 if __name__ == '__main__':
--- a/tools/plot-values/scatter.py	Thu May 14 17:43:19 2009 -0700
+++ b/tools/plot-values/scatter.py	Thu Jul 09 07:47:22 2009 -0700
@@ -6,7 +6,7 @@
 import  os.path         as     osp
 
 
-def plot(val1_fn, val2_fn):
+def plot(val1_fn, val2_fn, outfn = None):
     values1 = []
     with open(val1_fn) as fp:
         for line in fp.xreadlines():
@@ -21,15 +21,23 @@
     values2 = [v % 1. for v in values2]
     print min(values1), max(values2), min(values1), min(values2)
 
-    scatter(values1, values2)
+    scatter(values1, values2, s=10)
     axes().set_aspect('equal')
-    show()
+    if not outfn:
+        show()
+    else:
+        savefig(outfn)
 
 if __name__ == '__main__':
     if len(argv) < 3:
-        print "Usage: %s VALUES1 VALUES2" % argv[0]
+        print "Usage: %s VALUES1 VALUES2 [OUTPUT]" % argv[0]
         exit()
 
     val1_fn = argv[1]
     val2_fn  = argv[2]
-    plot(val1_fn, val2_fn)
+    
+    outfn = None
+    if len(argv) > 3: 
+        outfn = argv[3]
+
+    plot(val1_fn, val2_fn, outfn)