changeset 117:0adf95bdda00

what a waste of time and i still dont have a plot
author Jeff Hammel <k0scist@gmail.com>
date Sun, 15 Mar 2015 20:41:57 -0700
parents fe820a3afa48
children f98db1657dfa
files numerics/bar.py
diffstat 1 files changed, 30 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/numerics/bar.py	Sun Mar 15 20:18:00 2015 -0700
+++ b/numerics/bar.py	Sun Mar 15 20:41:57 2015 -0700
@@ -11,16 +11,18 @@
 # imports
 import argparse
 import sys
+import tempfile
 from .data import transpose
 from .manipulate import ManipulationParser
-from bokeh.charts import Bar
-from bokeh.plotting import *
+#from bokeh.charts import Bar
+#from bokeh.plotting import *
+from bokeh.plotting import figure, output_file, show, VBox
 from collections import OrderedDict
 
 __all__ = ['bar_chart', 'BarChartParser', 'main']
 
 
-def bar_chart(data, title=None):
+def bar_chart(data, output, title=None):
     """
     create a bar chart
 
@@ -31,20 +33,20 @@
 
 
     # create a figure
-#    p1 = figure(title=title,
-#                tools="pan,wheel_zoom,box_zoom,reset,resize",
-#                x_range=data[0]
-#            )
-#    if not len(data) == 2:
-#        raise NotImplementedError('TODO') # -> record TODO items
+    p1 = figure(title=title,
+                tools="pan,wheel_zoom,box_zoom,reset,resize",
+                x_range=data[0]
+            )
+    if not len(data) == 2:
+        raise NotImplementedError('TODO') # -> record TODO items
 
-#    p1.rect(x=data[0], height=data[1])
-#    p1.show()
+    p1.rect(x=data[0], y=data[1], height=data[1], width=0.2)
+    show(p1)
 
-    bar = Bar(data, tools="pan,wheel_zoom,box_zoom,reset,resize")
+#    bar = Bar(data, tools="pan,wheel_zoom,box_zoom,reset,resize")
 #    bar.filename(output)
-    bar.width(len(data)*50)
-    bar.show()
+#    bar.width(len(data)*50)
+#    bar.show()
 
 
 class BarChartParser(ManipulationParser):
@@ -57,6 +59,18 @@
         self.add_argument('-t', '--title', dest='title',
                           help="plot title")
 
+    def plot_filename(self):
+        """determine the plot filename"""
+        # this is a STUB
+        # in reality, this should come from -o, --output
+        # if applicable, or, should be determined from
+        # the plot --title, or should be eg
+        # '20150315203424.html'
+        # we are doing this right nowe to work around the fact
+        # that bokeh, in particular, will just cry if you
+        # don't set this
+        return 'foo.html'
+
 
 def main(args=sys.argv[1:]):
     """CLI"""
@@ -77,7 +91,8 @@
 
 
     # generate bar chart
-    bar_chart(data, options.output)
+    bar_chart(data, parser.plot_filename(), title=options.title)
+#    bar_chart(data, options.output, title=options.title)
 
 # BBB keeping this around for reference;
 # we should probably move to a better parsing system at some point