gpx_reduce.py
changeset 3 f94099a0277a
parent 2 f93786d4f68e
child 4 1b96bb9de1f3
--- a/gpx_reduce.py	Mon Aug 21 14:07:37 2017 +0200
+++ b/gpx_reduce.py	Tue Aug 22 11:22:13 2017 +0200
@@ -379,28 +379,30 @@
 
     # plot result to screen
     if options.plot:
-        import pylab as pl
+        from subprocess import Popen, PIPE
+
         latm, lonm, elesum = xyz_to_latlonele(sumx, sumy, sumz)
 
         for trkseg in tracksegs_old:
-            y_old = []
-            x_old = []
+            data_old = []
             for trkpt in trkseg:
                 xy = project_to_meters(trkpt[0], trkpt[1], latm, lonm)
-                x_old.append(xy[0])
-                y_old.append(xy[1])
-            pl.plot(x_old, y_old, 'r.-')
+                data_old.append (xy)
         
         for trkseg in tracksegs_new:
-            y_new = []
-            x_new = []
+            data = []
             for trkpt in trkseg:
                 xy = project_to_meters(trkpt[0], trkpt[1], latm, lonm)
-                x_new.append(xy[0])
-                y_new.append(xy[1])
-            pl.plot(x_new, y_new, 'b.-')
-        pl.grid()
-        pl.gca().set_aspect('equal')
-        pl.xlabel('x [m]')
-        pl.ylabel('y [m]')
-        pl.show()
\ No newline at end of file
+                data.append (xy)
+
+        #~ gnuPlotCmd = ['gnuplot', '-persist']
+        gnuPlotCmd = ['gnuplot']
+        plot = Popen (gnuPlotCmd, stdin=PIPE, stdout=PIPE, stderr=PIPE)
+        plot.stdin.write (b"plot '-' with linespoints lc rgb 'red' pt 4, '-' with linespoints pt 6\n")
+        plot.stdin.write ("\n".join ('%f %f' % d for d in data).encode ())
+        plot.stdin.write (b'\ne\n')
+        plot.stdin.write ("\n".join ('%f %f' % d for d in data_old).encode ())
+        plot.stdin.write (b'\ne\n')
+        plot.stdin.flush ()
+        #~ raw_input ('druk')
+        while 1: time.sleep (1)