Revision: 5976
          http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5976&view=rev
Author:   mdboom
Date:     2008-08-05 19:02:30 +0000 (Tue, 05 Aug 2008)

Log Message:
-----------
Fix RGBA arrays in collections.

Modified Paths:
--------------
    trunk/matplotlib/lib/matplotlib/axes.py
    trunk/matplotlib/lib/matplotlib/collections.py
    trunk/matplotlib/lib/matplotlib/patches.py

Modified: trunk/matplotlib/lib/matplotlib/axes.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/axes.py     2008-08-05 17:44:55 UTC (rev 
5975)
+++ trunk/matplotlib/lib/matplotlib/axes.py     2008-08-05 19:02:30 UTC (rev 
5976)
@@ -3797,14 +3797,18 @@
         # if color looks like a color string, an RGB tuple or a
         # scalar, then repeat it by nbars
         if (is_string_like(color) or
-            (iterable(color) and len(color)==3 and nbars!=3) or
+            (iterable(color) and
+             len(color) in (3, 4) and
+             nbars != len(color)) or
             not iterable(color)):
             color = [color]*nbars
 
         # if edgecolor looks like a color string, an RGB tuple or a
         # scalar, then repeat it by nbars
         if (is_string_like(edgecolor) or
-            (iterable(edgecolor) and len(edgecolor)==3 and nbars!=3) or
+            (iterable(edgecolor) and
+             len(edgecolor) in (3, 4) and
+             nbars != len(edgecolor)) or
             not iterable(edgecolor)):
             edgecolor = [edgecolor]*nbars
 

Modified: trunk/matplotlib/lib/matplotlib/collections.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/collections.py      2008-08-05 17:44:55 UTC 
(rev 5975)
+++ trunk/matplotlib/lib/matplotlib/collections.py      2008-08-05 19:02:30 UTC 
(rev 5976)
@@ -332,6 +332,7 @@
         """
         if c is None: c = mpl.rcParams['patch.facecolor']
         self._facecolors = _colors.colorConverter.to_rgba_array(c, self._alpha)
+        self._facecolors_original = c
 
     set_facecolors = set_facecolor
 
@@ -363,6 +364,7 @@
         else:
             if c is None: c = mpl.rcParams['patch.edgecolor']
             self._edgecolors = _colors.colorConverter.to_rgba_array(c, 
self._alpha)
+            self._edgecolors_original = c
 
     set_edgecolors = set_edgecolor
 
@@ -378,11 +380,13 @@
         else:
             artist.Artist.set_alpha(self, alpha)
             try:
-                self._facecolors[:, 3] = alpha
+                self._facecolors = _colors.colorConverter.to_rgba_array(
+                    self._facecolors_original, self._alpha)
             except (AttributeError, TypeError, IndexError):
                 pass
             try:
-                self._edgecolors[:, 3] = alpha
+                self._edgecolors = _colors.colorConverter.to_rgba_array(
+                    self._edgecolors_original, self._alpha)
             except (AttributeError, TypeError, IndexError):
                 pass
 

Modified: trunk/matplotlib/lib/matplotlib/patches.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/patches.py  2008-08-05 17:44:55 UTC (rev 
5975)
+++ trunk/matplotlib/lib/matplotlib/patches.py  2008-08-05 19:02:30 UTC (rev 
5976)
@@ -263,7 +263,6 @@
             gc.set_linewidth(self._linewidth)
             gc.set_linestyle(self._linestyle)
 
-        gc.set_alpha(self._alpha)
         gc.set_antialiased(self._antialiased)
         self._set_gc_clip(gc)
         gc.set_capstyle('projecting')
@@ -271,8 +270,11 @@
         if (not self.fill or self._facecolor is None or
             (cbook.is_string_like(self._facecolor) and 
self._facecolor.lower()=='none')):
             rgbFace = None
+            gc.set_alpha(1.0)
         else:
-            rgbFace = colors.colorConverter.to_rgb(self._facecolor)
+            r, g, b, a = colors.colorConverter.to_rgba(self._facecolor, 
self._alpha)
+            rgbFace = (r, g, b)
+            gc.set_alpha(a)
 
         if self._hatch:
             gc.set_hatch(self._hatch )


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 the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Matplotlib-checkins mailing list
Matplotlib-checkins@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-checkins

Reply via email to