From 28bece83f5279b6119a05310a58bb4b77b6115dc Mon Sep 17 00:00:00 2001
From: Gabriel Studer <gabriel.studer@stud.unibas.ch>
Date: Fri, 17 Aug 2012 13:59:49 +0200
Subject: [PATCH] allow user to pass custom colormaps in plothexbin

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

diff --git a/modules/base/pymod/table.py b/modules/base/pymod/table.py
index fe5d52811..055aade54 100644
--- a/modules/base/pymod/table.py
+++ b/modules/base/pymod/table.py
@@ -1392,8 +1392,9 @@ Statistics for column %(col)s
                     will be the lower bounds of the bins.
     
     :param colormap: colormap, that will be used. Value can be every colormap defined
-                     in matplotlib
-    :type colormap: :class:`str`
+                     in matplotlib or an own defined colormap. You can either pass a
+                     string with the name of the matplotlib colormap or a colormap
+                     object.
 
     :param show_scalebar: If set to True, a scalebar according to the chosen colormap is shown
     :type show_scalebar: :class:`bool`
@@ -1444,7 +1445,8 @@ Statistics for column %(col)s
     if title==None:
       title = '%s vs. %s' % (nice_x, nice_y)
   
-    colormap_object=eval('cm.'+colormap)
+    if IsStringLike(colormap):
+      colormap=getattr(cm, colormap)
 
     if x_range and (IsScalar(x_range) or len(x_range)!=2):
       raise ValueError('parameter x_range must contain exactly two elements')
@@ -1456,7 +1458,7 @@ Statistics for column %(col)s
     if y_range:
       plt.ylim(y_range[0], y_range[1])
 
-    plt.hexbin(xdata, ydata, bins=binning, cmap=colormap_object)
+    plt.hexbin(xdata, ydata, bins=binning, cmap=colormap)
 
     plt.title(title, size='x-large', fontweight='bold',
               verticalalignment='bottom')
-- 
GitLab