@@ -3952,6 +3952,7 @@ def scatter(self, x, y, s=None, c=None, marker=None, cmap=None, norm=None,
39523952
39533953 # np.ma.ravel yields an ndarray, not a masked array,
39543954 # unless its argument is a masked array.
3955+ xy_shape = (np .shape (x ), np .shape (y ))
39553956 x = np .ma .ravel (x )
39563957 y = np .ma .ravel (y )
39573958 if x .size != y .size :
@@ -3974,7 +3975,7 @@ def scatter(self, x, y, s=None, c=None, marker=None, cmap=None, norm=None,
39743975 else :
39753976 try :
39763977 c_array = np .asanyarray (c , dtype = float )
3977- if c_array .size == x . size :
3978+ if c_array .shape in xy_shape :
39783979 c = np .ma .ravel (c_array )
39793980 else :
39803981 # Wrong size; it must not be intended for mapping.
@@ -3984,7 +3985,14 @@ def scatter(self, x, y, s=None, c=None, marker=None, cmap=None, norm=None,
39843985 c_array = None
39853986
39863987 if c_array is None :
3987- colors = c # must be acceptable as PathCollection facecolors
3988+ try :
3989+ # must be acceptable as PathCollection facecolors
3990+ colors = mcolors .to_rgba_array (c )
3991+ except ValueError :
3992+ # c not acceptable as PathCollection facecolor
3993+ msg = ("c of shape {0} not acceptable as a color sequence "
3994+ "for x with size {1}, y with size {2}" )
3995+ raise ValueError (msg .format (c .shape , x .size , y .size ))
39883996 else :
39893997 colors = None # use cmap, norm after collection is created
39903998
0 commit comments