@@ -4949,8 +4949,8 @@ def scatter(self, x, y, s=20, c='b', marker='o', cmap=None, norm=None,
49494949 vmin=None, vmax=None, alpha=1.0, linewidths=None,
49504950 verts=None, **kwargs)
49514951
4952- Make a scatter plot of *x* versus *y*, where *x*, *y* are 1-D
4953- sequences of the same length, *N*.
4952+ Make a scatter plot of *x* versus *y*, where *x*, *y* are
4953+ converted to 1-D sequences which must be of the same length, *N*.
49544954
49554955 Keyword arguments:
49564956
@@ -5088,24 +5088,35 @@ def scatter(self, x, y, s=20, c='b', marker='o', cmap=None, norm=None,
50885088 x = self .convert_xunits (x )
50895089 y = self .convert_yunits (y )
50905090
5091+ # np.ma.ravel yields an ndarray, not a masked array,
5092+ # unless its argument is a masked array.
5093+ x = np .ma .ravel (x )
5094+ y = np .ma .ravel (y )
5095+ if x .size != y .size :
5096+ raise ValueError ("x and y must be the same size" )
5097+
5098+ s = np .ma .ravel (s ) # This doesn't have to match x, y in size.
5099+
5100+ c_is_stringy = is_string_like (c ) or cbook .is_sequence_of_strings (c )
5101+ if not c_is_stringy :
5102+ c = np .asanyarray (c )
5103+ if c .size == x .size :
5104+ c = np .ma .ravel (c )
5105+
50915106 x , y , s , c = cbook .delete_masked_points (x , y , s , c )
50925107
5108+ scales = s # Renamed for readability below.
50935109
5094- if is_string_like ( c ) or cbook . is_sequence_of_strings ( c ) :
5110+ if c_is_stringy :
50955111 colors = mcolors .colorConverter .to_rgba_array (c , alpha )
50965112 else :
5097- sh = np .shape (c )
50985113 # The inherent ambiguity is resolved in favor of color
50995114 # mapping, not interpretation as rgb or rgba:
5100- if len ( sh ) == 1 and sh [ 0 ] == len ( x ) :
5115+ if c . size == x . size :
51015116 colors = None # use cmap, norm after collection is created
51025117 else :
51035118 colors = mcolors .colorConverter .to_rgba_array (c , alpha )
51045119
5105- if not iterable (s ):
5106- scales = (s ,)
5107- else :
5108- scales = s
51095120
51105121 if faceted :
51115122 edgecolors = None
0 commit comments