changeset 129:79d99216ba17

cleanup and remove image display
author Jeff Hammel <k0scist@gmail.com>
date Mon, 16 Mar 2015 21:14:03 -0700
parents 63bf582841a3
children d3ed3a0092d1
files numerics/plot.py
diffstat 1 files changed, 5 insertions(+), 30 deletions(-) [+]
line wrap: on
line diff
--- a/numerics/plot.py	Mon Mar 16 20:59:08 2015 -0700
+++ b/numerics/plot.py	Mon Mar 16 21:14:03 2015 -0700
@@ -24,38 +24,12 @@
 import sys
 import tempfile
 import time
-from which import which
-from StringIO import StringIO
 
 # module globals
-__all__ = ['Displayer', 'Plot', 'PlotParser', 'read', 'main']
+__all__ = ['Plot', 'PlotParser', 'read', 'main']
 string = (str, unicode)
 
 
-class Displayer(object):
-    """image displayer"""
-    viewers = ('feh', 'qiv', 'sxiv')
-
-    def __init__(self, viewers=None):
-        if viewers is None:
-            viewers = self.viewers
-        self.viewers = viewers
-
-    def viewer(self):
-        """returns path to primary viewer"""
-        for viewer in self.viewers:
-            path = which(viewer)
-            if path:
-                return path
-
-    def __call__(self, image):
-        """display an image and exit"""
-        viewer = self.viewer()
-        if viewer:
-            args = [viewer, image]
-            subprocess.check_output(args)
-
-
 class Plot(object):
     """plotting class"""
     def __init__(self, title=None, xlabel=None, ylabel=None):
@@ -125,11 +99,11 @@
 class PlotParser(argparse.ArgumentParser):
     """CLI option parser for the plotter"""
 
+    types = (float,)
+
     def __init__(self, *args, **kwargs):
         kwargs.setdefault('description', __doc__)
         argparse.ArgumentParser.__init__(self, *args, **kwargs)
-        self.add_argument('--info', dest='info',
-                            help="display info and exit")
         self.add_argument('input',
                           type=argparse.FileType('r'), nargs='*',
                           default=(sys.stdin,),
@@ -158,6 +132,7 @@
     parser = PlotParser()
     options = parser.parse_args(args)
 
+    # choose plotting function
     plot_fcn = plt.scatter if options.scatter else plt.plot
 
     # read data
@@ -169,7 +144,7 @@
     colors = iter(cm.rainbow(np.linspace(0, 1, n_col)))
 
     for data in all_data:
-        # plot it
+        # plot each data set
         if len(data) == 1:
             plot_fcn(*data, marker='.', color=next(colors))
         else: