Revision: 5975
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5975&view=rev
Author: mdboom
Date: 2008-08-05 17:44:55 +0000 (Tue, 05 Aug 2008)
Log Message:
-----------
Fix Nx3 color array bug.
Modified Paths:
--------------
trunk/matplotlib/lib/matplotlib/colors.py
Modified: trunk/matplotlib/lib/matplotlib/colors.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/colors.py 2008-08-05 17:25:12 UTC (rev
5974)
+++ trunk/matplotlib/lib/matplotlib/colors.py 2008-08-05 17:44:55 UTC (rev
5975)
@@ -337,11 +337,21 @@
# If c is a list it must be maintained as the same list
# with modified items so that items can be appended to
# it. This is needed for examples/dynamic_collections.py.
- if not isinstance(c, (list, np.ndarray)): # specific; don't need
duck-typing
- c = list(c)
+ if isinstance(c, np.ndarray):
+ if len(c.shape) != 2:
+ raise ValueError("Color array must be two-dimensional")
+ if c.shape[1] != 4:
+ output = np.zeros((c.shape[0], 4))
+ else:
+ output = c
+ elif not isinstance(c, list):
+ output = list(c)
+ else:
+ output = c
+
for i, cc in enumerate(c):
- c[i] = self.to_rgba(cc, alpha) # change in place
- result = c
+ output[i] = self.to_rgba(cc, alpha) # change in place
+ result = output
return np.asarray(result, np.float_)
colorConverter = ColorConverter()
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
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-checkins