[Rivet-svn] r3518 - in trunk: bin doc

blackhole at projects.hepforge.org blackhole at projects.hepforge.org
Wed Dec 7 20:37:07 GMT 2011


Author: fsiegert
Date: Wed Dec  7 20:37:07 2011
New Revision: 3518

Log:
make-plots: Add PlotOrder=<int> and LegendOrder=<int> options for moving individual histograms up/down in the plot or legend ordering.

Modified:
   trunk/bin/make-plots
   trunk/doc/make-plots.txt

Modified: trunk/bin/make-plots
==============================================================================
--- trunk/bin/make-plots	Wed Dec  7 12:02:30 2011	(r3517)
+++ trunk/bin/make-plots	Wed Dec  7 20:37:07 2011	(r3518)
@@ -122,15 +122,25 @@
         if self.description.has_key('Rebin'):
             for i in self.histos:
                 self.histos[i].description['Rebin'] = self.description['Rebin']
+        if self.description.has_key('EnvelopeRebin'):
+            for i in self.histos:
+                self.histos[i].description['EnvelopeRebin'] = self.description['EnvelopeRebin']
 
-        foo=[]
+        histoordermap = {}
+        histolist = self.histos.keys()
         if self.description.has_key('DrawOnly'):
-            for i in self.description['DrawOnly'].strip().split():
-                if i in self.histos.keys():
-                    foo.append(i)
-        else:
-            foo=self.histos.keys()
-        self.description['DrawOnly']=foo
+            histolist = filter(self.histos.keys().count, self.description['DrawOnly'].strip().split())
+        for histo in histolist:
+            order = 0
+            if self.histos[histo].description.has_key('PlotOrder'):
+                order = int(self.histos[histo].description['PlotOrder'])
+            if not order in histoordermap:
+                histoordermap[order] = []
+            histoordermap[order].append(histo)
+        sortedhistolist = []
+        for i in sorted(histoordermap.keys()):
+            sortedhistolist.extend(histoordermap[i])
+        self.description['DrawOnly']=sortedhistolist
 
 
     def read_input(self, f):
@@ -786,13 +796,26 @@
         out += '\n%\n% Legend\n%\n'
         out += '\\rput[tr](%s,%s){%%\n' % (self.getLegendXPos(), self.getLegendYPos())
         ypos = -0.05*6/self.description['PlotSizeY']
-        foo=[]
+
+        legendordermap = {}
+        legendlist = self.description['DrawOnly']+self.functions.keys()
         if self.description.has_key('LegendOnly'):
-            for i in self.description['LegendOnly'].strip().split():
-                if i in self.histos.keys() or i in self.functions.keys():
-                    foo.append(i)
-        else:
-            foo=self.description['DrawOnly']+self.functions.keys()
+            legendlist = []
+            for legend in self.description['LegendOnly'].strip().split():
+                if legend in self.histos.keys() or legend in self.functions.keys():
+                    legendlist.append(legend)
+        for legend in legendlist:
+            order = 0
+            if self.histos.has_key(legend) and self.histos[legend].description.has_key('LegendOrder'):
+                order = int(self.histos[legend].description['LegendOrder'])
+            if self.functions.has_key(legend) and self.functions[legend].description.has_key('LegendOrder'):
+                order = int(self.functions[legend].description['LegendOrder'])
+            if not order in legendordermap:
+                legendordermap[order] = []
+            legendordermap[order].append(legend)
+        foo=[]
+        for i in sorted(legendordermap.keys()):
+            foo.extend(legendordermap[i])
 
         for i in foo:
             if self.histos.has_key(i):

Modified: trunk/doc/make-plots.txt
==============================================================================
--- trunk/doc/make-plots.txt	Wed Dec  7 12:02:30 2011	(r3517)
+++ trunk/doc/make-plots.txt	Wed Dec  7 20:37:07 2011	(r3518)
@@ -240,7 +240,11 @@
 --------------------
 Whitespace separated list of IDs. These can be histograms or functions. The
 legend is only shown for the listed objects. Without this option, all plotted
-objects which have a title enter the legend.
+objects which have a title enter the legend. The legend titles
+are plotted in the given order, so there are cases in which it makes
+sense to use `LegendOnly` together with all histogram IDs.
+It is also possible to specify the legend order on an entry-by-entry basis
+using the `LegendOrder=<int>` setting for each histogram or function.
 
 
 Plotting Options
@@ -253,7 +257,9 @@
 are plotted, even if there are more histograms defined in the file. The
 histograms are plotted in the given order, so there are cases in which it makes
 sense to use `DrawOnly` together with all histogram IDs. This is especially
-useful for the `Stack` option.
+useful for the `Stack` option. It is also possible to specify the plotting order
+on a histogram-by-histogram basis using the `PlotOrder=<int>` setting for each
+histogram.
 
 --------------------
 Stack=<list>


More information about the Rivet-svn mailing list