From dbe0c6c39e2a3c47897e4b33208af8f9f2d19325 Mon Sep 17 00:00:00 2001
From: Marco Biasini <mvbiasini@gmail.com>
Date: Tue, 19 Jun 2012 17:34:08 +0200
Subject: [PATCH] added color option to PlotHistogram

---
 modules/base/pymod/table.py | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/modules/base/pymod/table.py b/modules/base/pymod/table.py
index b88f983be..81e5b5f46 100644
--- a/modules/base/pymod/table.py
+++ b/modules/base/pymod/table.py
@@ -1142,7 +1142,8 @@ class Table(object):
     
   def PlotHistogram(self, col, x_range=None, num_bins=10, normed=False,
                     histtype='stepfilled', align='mid', x_title=None,
-                    y_title=None, title=None, clear=True, save=False):
+                    y_title=None, title=None, clear=True, save=False,
+                    color=None):
     """
     Create a histogram of the data in col for the range *x_range*, split into
     *num_bins* bins and plot it using Matplotlib.
@@ -1202,7 +1203,9 @@ class Table(object):
       
       if len(self.rows)==0:
         return None
-      
+      kwargs={}
+      if color:
+        kwargs['color']=color
       idx = self.GetColIndex(col)
       data = []
       for r in self.rows:
@@ -1213,21 +1216,22 @@ class Table(object):
         plt.clf()
         
       n, bins, patches = plt.hist(data, bins=num_bins, range=x_range,
-                                  normed=normed, histtype=histtype, align=align)
+                                  normed=normed, histtype=histtype, align=align,
+                                  **kwargs)
       
-      if x_title:
+      if x_title!=None:
         nice_x=x_title
       else:
         nice_x=MakeTitle(col)
       plt.xlabel(nice_x, size='x-large')
       
-      if y_title:
+      if y_title!=None:
         nice_y=y_title
       else:
         nice_y="bin count"  
       plt.ylabel(nice_y, size='x-large')
       
-      if title:
+      if title!=None:
         nice_title=title
       else:
         nice_title="Histogram of %s"%nice_x
-- 
GitLab