[Rivet-svn] r3611 - in trunk: . bin pyext

blackhole at projects.hepforge.org blackhole at projects.hepforge.org
Fri Mar 16 12:39:26 GMT 2012


Author: hoeth
Date: Fri Mar 16 12:39:26 2012
New Revision: 3611

Log:
improve default plot behaviour for 2D histograms

Modified:
   trunk/ChangeLog
   trunk/bin/compare-histos
   trunk/pyext/lighthisto.py

Modified: trunk/ChangeLog
==============================================================================
--- trunk/ChangeLog	Thu Mar 15 13:49:29 2012	(r3610)
+++ trunk/ChangeLog	Fri Mar 16 12:39:26 2012	(r3611)
@@ -1,3 +1,7 @@
+2012-03-16  Hendrik Hoeth <hendrik.hoeth at cern.ch>
+
+	* Improve default plot behaviour for 2D histograms
+
 2012-03-15  Hendrik Hoeth <hendrik.hoeth at cern.ch>
 
 	* Make ATLAS_2012_I1084540 less verbose, and general code

Modified: trunk/bin/compare-histos
==============================================================================
--- trunk/bin/compare-histos	Thu Mar 15 13:49:29 2012	(r3610)
+++ trunk/bin/compare-histos	Fri Mar 16 12:39:26 2012	(r3611)
@@ -453,19 +453,35 @@
             logging.debug("Could not get plot headers: %s" % err)
             headers = {}
 
+        is2dim = False
+        if HISTOS[activefiles[0]][name].is2dim():
+            is2dim = True
+        if is2dim and len(activefiles)>1:
+            logging.warning("More than one histogram file for 2-dim histogram '%s', only using first file" % name)
+            activefiles = [activefiles[0]]
+
         drawonlystr = ""
         for hfile in activefiles:
             drawonlystr += hfile.replace(' ','_') + HISTOS[hfile][name].fullPath().replace(' ','_') + " "
-        paramdefaults = {"Title" : title,
-                         "XLabel" : xlabel,
-                         "YLabel" : ylabel,
-                         "Legend" : "1",
-                         "LogY" : "%d" % int((len(HISTOS[ref][name].getBins()) > 1) and not opts.LINEAR),
-                         "DrawOnly" : drawonlystr,
-                         "RatioPlot" : "%d" % int(not opts.NORATIO),
-                         "XTwosidedTicks" : "1",
-                         "YTwosidedTicks" : "1",
-                         "RatioPlotReference" : "%s%s" % (ref.replace(' ','_'), HISTOS[ref][name].fullPath().replace(' ','_'))}
+        paramdefaults = {}
+        if not is2dim:
+            paramdefaults = {"Title" : title,
+                             "XLabel" : xlabel,
+                             "YLabel" : ylabel,
+                             "Legend" : "1",
+                             "LogY" : "%d" % int((len(HISTOS[ref][name].getBins()) > 1) and not opts.LINEAR),
+                             "DrawOnly" : drawonlystr,
+                             "RatioPlot" : "%d" % int(not opts.NORATIO),
+                             "XTwosidedTicks" : "1",
+                             "YTwosidedTicks" : "1",
+                             "RatioPlotReference" : "%s%s" % (ref.replace(' ','_'), HISTOS[ref][name].fullPath().replace(' ','_'))}
+        else:
+            paramdefaults = {"Title" : title,
+                             "XLabel" : xlabel,
+                             "YLabel" : ylabel,
+                             "Legend" : "1",
+                             "XTwosidedTicks" : "1",
+                             "YTwosidedTicks" : "1"}
 
 
         if opts.RATIO_DEVIATION:
@@ -526,8 +542,12 @@
                 color, style = STYLES[i % len(STYLES)]
                 if opts.MC_ERRS:
                     histstr += "ErrorBars=1\n"
-                histstr += 'LineColor=%s\n' % color
-                histstr += 'LineStyle=%s\n' % style
+                if not is2dim:
+                    histstr += 'LineColor=%s\n' % color
+                    histstr += 'LineStyle=%s\n' % style
+                else:
+                    histstr += 'LineStyle=none\n'
+                    histstr += 'LineWidth=0pt\n'
                 histstr += 'Title=%s\n' % LABELS[hfile][name]
                 for key, val in histopts.iteritems():
                     #if key == 'ErrorBars' and opts.MC_ERRS:

Modified: trunk/pyext/lighthisto.py
==============================================================================
--- trunk/pyext/lighthisto.py	Thu Mar 15 13:49:29 2012	(r3610)
+++ trunk/pyext/lighthisto.py	Fri Mar 16 12:39:26 2012	(r3611)
@@ -178,6 +178,11 @@
         r += ind + "</dataPointSet>\n"
         return r
 
+    def is2dim(self):
+        if self.numBins()==0:
+            return False
+        return self._bins[0].is2dim()
+
     def numBins(self):
         return len(self._bins)
 
@@ -466,8 +471,13 @@
                 self.val, self.errplus, self.errminus)
         return out
 
-    def asFlat(self):
+    def is2dim(self):
         if self.ylow is None or self.yhigh is None:
+            return False
+        return True
+
+    def asFlat(self):
+        if not self.is2dim():
             out = "%e\t%e\t%e\t%e\t%e" % (self.xlow, self.xhigh, self.val, self.errminus, self.errplus)
         else:
             out = "%e\t%e\t%e\t%e\t%e\t%e" % (self.xlow, self.xhigh, self.ylow, self.yhigh, self.val, 0.5*(self.errminus+self.errplus))


More information about the Rivet-svn mailing list