@@ -4281,19 +4281,26 @@ def invalid_shape_exception(csize, xsize):
4281
4281
except ValueError :
4282
4282
pass # Failed to convert to float array; must be color specs.
4283
4283
else :
4284
+ # handle the documented special case of a 2D array with 1
4285
+ # row which as RGB(A) to broadcast.
4286
+ if c .shape == (1 , 4 ) or c .shape == (1 , 3 ):
4287
+ c_is_mapped = False
4288
+ if c .size != xsize :
4289
+ valid_shape = False
4284
4290
# If c can be either mapped values or a RGB(A) color, prefer
4285
4291
# the former if shapes match, the latter otherwise.
4286
- if c .size == xsize :
4292
+ elif c .size == xsize :
4287
4293
c = c .ravel ()
4288
4294
c_is_mapped = True
4289
4295
else : # Wrong size; it must not be intended for mapping.
4290
4296
if c .shape in ((3 ,), (4 ,)):
4291
4297
_log .warning (
4292
- "'c' argument looks like a single numeric RGB or "
4298
+ "*c* argument looks like a single numeric RGB or "
4293
4299
"RGBA sequence, which should be avoided as value-"
4294
4300
"mapping will have precedence in case its length "
4295
- "matches with 'x' & 'y'. Please use a 2-D array "
4296
- "with a single row if you really want to specify "
4301
+ "matches with *x* & *y*. Please use the *color* "
4302
+ "keyword-argument or provide a 2-D array "
4303
+ "with a single row if you intend to specify "
4297
4304
"the same RGB or RGBA value for all points." )
4298
4305
valid_shape = False
4299
4306
if not c_is_mapped :
@@ -4340,14 +4347,14 @@ def scatter(self, x, y, s=None, c=None, marker=None, cmap=None, norm=None,
4340
4347
The marker size in points**2.
4341
4348
Default is ``rcParams['lines.markersize'] ** 2``.
4342
4349
4343
- c : color or list of colors or array-like , optional
4344
- The marker color . Possible values:
4350
+ c : array-like or list of colors or color , optional
4351
+ The marker colors . Possible values:
4345
4352
4346
- - A single color format string.
4347
- - A sequence of colors of length n.
4348
4353
- A scalar or sequence of n numbers to be mapped to colors using
4349
4354
*cmap* and *norm*.
4350
4355
- A 2-D array in which the rows are RGB or RGBA.
4356
+ - A sequence of colors of length n.
4357
+ - A single color format string.
4351
4358
4352
4359
Note that *c* should not be a single numeric RGB or RGBA sequence
4353
4360
because that is indistinguishable from an array of values to be
@@ -4356,9 +4363,12 @@ def scatter(self, x, y, s=None, c=None, marker=None, cmap=None, norm=None,
4356
4363
matching will have precedence in case of a size matching with *x*
4357
4364
and *y*.
4358
4365
4359
- Defaults to ``None``. In that case the marker color is determined
4360
- by the value of ``color``, ``facecolor`` or ``facecolors``. In case
4361
- those are not specified or ``None``, the marker color is determined
4366
+ If you wish to specify a single color for all points
4367
+ prefer the *color* keyword argument.
4368
+
4369
+ Defaults to `None`. In that case the marker color is determined
4370
+ by the value of *color*, *facecolor* or *facecolors*. In case
4371
+ those are not specified or `None`, the marker color is determined
4362
4372
by the next color of the ``Axes``' current "shape and fill" color
4363
4373
cycle. This cycle defaults to :rc:`axes.prop_cycle`.
4364
4374
0 commit comments