Revision: 4330
          http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4330&view=rev
Author:   mdboom
Date:     2007-11-16 05:28:44 -0800 (Fri, 16 Nov 2007)

Log Message:
-----------
Merged revisions 4318-4329 via svnmerge from 
http://matplotlib.svn.sf.net/svnroot/matplotlib/trunk/matplotlib

........
  r4325 | dsdale | 2007-11-15 16:23:27 -0500 (Thu, 15 Nov 2007) | 4 lines
  
  added npy.seterr(invalid='ignore') to beginning of axes.py, to silence 
  repeated warnings created by finding extrema of arrays containing nans
  (discovered during calls to errorbar)
........
  r4328 | efiring | 2007-11-16 02:47:51 -0500 (Fri, 16 Nov 2007) | 2 lines
  
  ScalarMappable.to_rgba can return uint8 instead of float64
........
  r4329 | dsdale | 2007-11-16 08:16:12 -0500 (Fri, 16 Nov 2007) | 2 lines
  
  removed numpy.seterr(invalid='ignore') from axes.py
........

Modified Paths:
--------------
    branches/transforms/lib/matplotlib/axes.py
    branches/transforms/lib/matplotlib/cm.py
    branches/transforms/lib/matplotlib/colors.py

Property Changed:
----------------
    branches/transforms/


Property changes on: branches/transforms
___________________________________________________________________
Name: svnmerge-integrated
   - /trunk/matplotlib:1-4317
   + /trunk/matplotlib:1-4329

Modified: branches/transforms/lib/matplotlib/axes.py
===================================================================
--- branches/transforms/lib/matplotlib/axes.py  2007-11-16 13:16:12 UTC (rev 
4329)
+++ branches/transforms/lib/matplotlib/axes.py  2007-11-16 13:28:44 UTC (rev 
4330)
@@ -2597,7 +2597,6 @@
 
         self._process_unit_info(xdata=x, ydata=ymin, kwargs=kwargs)
 
-
         if not iterable(x): x = [x]
         if not iterable(ymin): ymin = [ymin]
         if not iterable(ymax): ymax = [ymax]

Modified: branches/transforms/lib/matplotlib/cm.py
===================================================================
--- branches/transforms/lib/matplotlib/cm.py    2007-11-16 13:16:12 UTC (rev 
4329)
+++ branches/transforms/lib/matplotlib/cm.py    2007-11-16 13:28:44 UTC (rev 
4330)
@@ -45,14 +45,18 @@
         'set the colorbar image and axes associated with mappable'
         self.colorbar = im, ax
 
-    def to_rgba(self, x, alpha=1.0):
+    def to_rgba(self, x, alpha=1.0, bytes=False):
         '''Return a normalized rgba array corresponding to x.
         If x is already an rgb or rgba array, return it unchanged.
         '''
-        if hasattr(x, 'shape') and len(x.shape)>2: return x
+        try:
+            if x.ndim == 3 and (x.shape[2] == 3 or x.shape[2] == 4):
+                return x
+        except AttributeError:
+            pass
         x = ma.asarray(x)
         x = self.norm(x)
-        x = self.cmap(x, alpha)
+        x = self.cmap(x, alpha=alpha, bytes=bytes)
         return x
 
     def set_array(self, A):

Modified: branches/transforms/lib/matplotlib/colors.py
===================================================================
--- branches/transforms/lib/matplotlib/colors.py        2007-11-16 13:16:12 UTC 
(rev 4329)
+++ branches/transforms/lib/matplotlib/colors.py        2007-11-16 13:28:44 UTC 
(rev 4330)
@@ -407,7 +407,7 @@
         self._isinit = False
 
 
-    def __call__(self, X, alpha=1.0):
+    def __call__(self, X, alpha=1.0, bytes=False):
         """
         X is either a scalar or an array (of any dimension).
         If scalar, a tuple of rgba values is returned, otherwise
@@ -416,6 +416,8 @@
         If they are floating point, then they must be in the
         interval (0.0, 1.0).
         Alpha must be a scalar.
+        If bytes is False, the rgba values will be floats on a
+        0-1 scale; if True, they will be uint8, 0-255.
         """
 
         if not self._isinit: self._init()
@@ -440,7 +442,11 @@
         npy.putmask(xa, xa<0, self._i_under)
         if mask_bad is not None and mask_bad.shape == xa.shape:
             npy.putmask(xa, mask_bad, self._i_bad)
-        rgba = self._lut[xa]
+        if bytes:
+            lut = (self._lut * 255).astype(npy.uint8)
+        else:
+            lut = self._lut
+        rgba = lut[xa]
         if vtype == 'scalar':
             rgba = tuple(rgba[0,:])
         return rgba


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Matplotlib-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-checkins

Reply via email to