@@ -4212,19 +4212,26 @@ def invalid_shape_exception(csize, xsize):
4212
4212
except ValueError :
4213
4213
pass # Failed to convert to float array; must be color specs.
4214
4214
else :
4215
+ # handle the documented special case of a 2D array with 1
4216
+ # row which as RGB(A) to broadcast.
4217
+ if c .shape == (1 , 4 ) or c .shape == (1 , 3 ):
4218
+ c_is_mapped = False
4219
+ if c .size != xsize :
4220
+ valid_shape = False
4215
4221
# If c can be either mapped values or a RGB(A) color, prefer
4216
4222
# the former if shapes match, the latter otherwise.
4217
- if c .size == xsize :
4223
+ elif c .size == xsize :
4218
4224
c = c .ravel ()
4219
4225
c_is_mapped = True
4220
4226
else : # Wrong size; it must not be intended for mapping.
4221
4227
if c .shape in ((3 ,), (4 ,)):
4222
4228
_log .warning (
4223
- "'c' argument looks like a single numeric RGB or "
4229
+ "*c* argument looks like a single numeric RGB or "
4224
4230
"RGBA sequence, which should be avoided as value-"
4225
4231
"mapping will have precedence in case its length "
4226
- "matches with 'x' & 'y'. Please use a 2-D array "
4227
- "with a single row if you really want to specify "
4232
+ "matches with *x* & *y*. Please use the *color* "
4233
+ "keyword-argument or provide a 2-D array "
4234
+ "with a single row if you intend to specify "
4228
4235
"the same RGB or RGBA value for all points." )
4229
4236
valid_shape = False
4230
4237
if not c_is_mapped :
@@ -4268,14 +4275,14 @@ def scatter(self, x, y, s=None, c=None, marker=None, cmap=None, norm=None,
4268
4275
The marker size in points**2.
4269
4276
Default is ``rcParams['lines.markersize'] ** 2``.
4270
4277
4271
- c : color, sequence, or sequence of colors, optional
4272
- The marker color . Possible values:
4278
+ c : array-like or list of colors or color , optional
4279
+ The marker colors . Possible values:
4273
4280
4274
- - A single color format string.
4275
- - A sequence of colors of length n.
4276
4281
- A scalar or sequence of n numbers to be mapped to colors using
4277
4282
*cmap* and *norm*.
4278
4283
- A 2-D array in which the rows are RGB or RGBA.
4284
+ - A sequence of colors of length n.
4285
+ - A single color format string.
4279
4286
4280
4287
Note that *c* should not be a single numeric RGB or RGBA sequence
4281
4288
because that is indistinguishable from an array of values to be
@@ -4284,9 +4291,12 @@ def scatter(self, x, y, s=None, c=None, marker=None, cmap=None, norm=None,
4284
4291
matching will have precedence in case of a size matching with *x*
4285
4292
and *y*.
4286
4293
4287
- Defaults to ``None``. In that case the marker color is determined
4288
- by the value of ``color``, ``facecolor`` or ``facecolors``. In case
4289
- those are not specified or ``None``, the marker color is determined
4294
+ If you wish to specify a single color for all points
4295
+ prefer the *color* keyword argument.
4296
+
4297
+ Defaults to `None`. In that case the marker color is determined
4298
+ by the value of *color*, *facecolor* or *facecolors*. In case
4299
+ those are not specified or `None`, the marker color is determined
4290
4300
by the next color of the ``Axes``' current "shape and fill" color
4291
4301
cycle. This cycle defaults to :rc:`axes.prop_cycle`.
4292
4302
0 commit comments