SF.net SVN: matplotlib:[6923] trunk/matplotlib

2009-02-21 Thread efiring
Revision: 6923
  http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6923&view=rev
Author:   efiring
Date: 2009-02-21 19:06:58 + (Sat, 21 Feb 2009)

Log Message:
---
Improve scatter argument handling

Modified Paths:
--
trunk/matplotlib/CHANGELOG
trunk/matplotlib/lib/matplotlib/axes.py

Modified: trunk/matplotlib/CHANGELOG
===
--- trunk/matplotlib/CHANGELOG  2009-02-18 19:44:29 UTC (rev 6922)
+++ trunk/matplotlib/CHANGELOG  2009-02-21 19:06:58 UTC (rev 6923)
@@ -1,3 +1,6 @@
+2009-02-21 Improve scatter argument handling; add an early error
+   message, allow inputs to have more than one dimension. - EF
+
 2009-02-16 Move plot_directive.py to the installed source tree.  Add
support for inline code content - MGD
 

Modified: trunk/matplotlib/lib/matplotlib/axes.py
===
--- trunk/matplotlib/lib/matplotlib/axes.py 2009-02-18 19:44:29 UTC (rev 
6922)
+++ trunk/matplotlib/lib/matplotlib/axes.py 2009-02-21 19:06:58 UTC (rev 
6923)
@@ -4949,8 +4949,8 @@
   vmin=None, vmax=None, alpha=1.0, linewidths=None,
   verts=None, **kwargs)
 
-Make a scatter plot of *x* versus *y*, where *x*, *y* are 1-D
-sequences of the same length, *N*.
+Make a scatter plot of *x* versus *y*, where *x*, *y* are
+converted to 1-D sequences which must be of the same length, *N*.
 
 Keyword arguments:
 
@@ -5088,24 +5088,35 @@
 x = self.convert_xunits(x)
 y = self.convert_yunits(y)
 
+# np.ma.ravel yields an ndarray, not a masked array,
+# unless its argument is a masked array.
+x = np.ma.ravel(x)
+y = np.ma.ravel(y)
+if x.size != y.size:
+raise ValueError("x and y must be the same size")
+
+s = np.ma.ravel(s)  # This doesn't have to match x, y in size.
+
+c_is_stringy = is_string_like(c) or cbook.is_sequence_of_strings(c)
+if not c_is_stringy:
+c = np.asanyarray(c)
+if c.size == x.size:
+c = np.ma.ravel(c)
+
 x, y, s, c = cbook.delete_masked_points(x, y, s, c)
 
+scales = s   # Renamed for readability below.
 
-if is_string_like(c) or cbook.is_sequence_of_strings(c):
+if c_is_stringy:
 colors = mcolors.colorConverter.to_rgba_array(c, alpha)
 else:
-sh = np.shape(c)
 # The inherent ambiguity is resolved in favor of color
 # mapping, not interpretation as rgb or rgba:
-if len(sh) == 1 and sh[0] == len(x):
+if c.size == x.size:
 colors = None  # use cmap, norm after collection is created
 else:
 colors = mcolors.colorConverter.to_rgba_array(c, alpha)
 
-if not iterable(s):
-scales = (s,)
-else:
-scales = s
 
 if faceted:
 edgecolors = None


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

--
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
___
Matplotlib-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-checkins


SF.net SVN: matplotlib:[6924] trunk/matplotlib/lib/matplotlib/units.py

2009-02-21 Thread efiring
Revision: 6924
  http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6924&view=rev
Author:   efiring
Date: 2009-02-21 20:14:08 + (Sat, 21 Feb 2009)

Log Message:
---
Add new axis arguments to units.py docstring

Modified Paths:
--
trunk/matplotlib/lib/matplotlib/units.py

Modified: trunk/matplotlib/lib/matplotlib/units.py
===
--- trunk/matplotlib/lib/matplotlib/units.py2009-02-21 19:06:58 UTC (rev 
6923)
+++ trunk/matplotlib/lib/matplotlib/units.py2009-02-21 20:14:08 UTC (rev 
6924)
@@ -19,12 +19,12 @@
 class DateConverter(units.ConversionInterface):
 
 @staticmethod
-def convert(value, unit):
+def convert(value, unit, axis):
 'convert value to a scalar or array'
 return dates.date2num(value)
 
 @staticmethod
-def axisinfo(unit):
+def axisinfo(unit, axis):
 'return major and minor tick locators and formatters'
 if unit!='date': return None
 majloc = dates.AutoDateLocator()
@@ -34,7 +34,7 @@
 label='date')
 
 @staticmethod
-def default_units(x):
+def default_units(x, axis):
 'return the default unit for x or None'
 return 'date'
 


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

--
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
___
Matplotlib-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-checkins