@@ -3952,6 +3952,7 @@ def scatter(self, x, y, s=None, c=None, marker=None, cmap=None, norm=None,
3952
3952
3953
3953
# np.ma.ravel yields an ndarray, not a masked array,
3954
3954
# unless its argument is a masked array.
3955
+ xy_shape = (np .shape (x ), np .shape (y ))
3955
3956
x = np .ma .ravel (x )
3956
3957
y = np .ma .ravel (y )
3957
3958
if x .size != y .size :
@@ -3974,7 +3975,7 @@ def scatter(self, x, y, s=None, c=None, marker=None, cmap=None, norm=None,
3974
3975
else :
3975
3976
try :
3976
3977
c_array = np .asanyarray (c , dtype = float )
3977
- if c_array .size == x . size :
3978
+ if c_array .shape in xy_shape :
3978
3979
c = np .ma .ravel (c_array )
3979
3980
else :
3980
3981
# 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,
3984
3985
c_array = None
3985
3986
3986
3987
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 ))
3988
3996
else :
3989
3997
colors = None # use cmap, norm after collection is created
3990
3998
0 commit comments