@@ -3511,7 +3511,8 @@ def dopatch(xs, ys, **kwargs):
3511
3511
@docstring .dedent_interpd
3512
3512
def scatter (self , x , y , s = 20 , c = 'b' , marker = 'o' , cmap = None , norm = None ,
3513
3513
vmin = None , vmax = None , alpha = None , linewidths = None ,
3514
- verts = None , ** kwargs ):
3514
+ verts = None , edgecolors = None ,
3515
+ ** kwargs ):
3515
3516
"""
3516
3517
Make a scatter plot of x vs y, where x and y are sequence like objects
3517
3518
of the same lengths.
@@ -3531,11 +3532,14 @@ def scatter(self, x, y, s=20, c='b', marker='o', cmap=None, norm=None,
3531
3532
(see below). Note that `c` should not be a single numeric RGB or
3532
3533
RGBA sequence because that is indistinguishable from an array of
3533
3534
values to be colormapped. `c` can be a 2-D array in which the
3534
- rows are RGB or RGBA, however.
3535
+ rows are RGB or RGBA, however, including the case of a single
3536
+ row to specify the same color for all points.
3535
3537
3536
3538
marker : `~matplotlib.markers.MarkerStyle`, optional, default: 'o'
3537
3539
See `~matplotlib.markers` for more information on the different
3538
- styles of markers scatter supports.
3540
+ styles of markers scatter supports. `marker` can be either
3541
+ an instance of the class or the text shorthand for a particular
3542
+ marker.
3539
3543
3540
3544
cmap : `~matplotlib.colors.Colormap`, optional, default: None
3541
3545
A `~matplotlib.colors.Colormap` instance or registered name.
@@ -3557,10 +3561,14 @@ def scatter(self, x, y, s=20, c='b', marker='o', cmap=None, norm=None,
3557
3561
The alpha blending value, between 0 (transparent) and 1 (opaque)
3558
3562
3559
3563
linewidths : scalar or array_like, optional, default: None
3560
- If None, defaults to (lines.linewidth,). Note that this is a
3561
- tuple, and if you set the linewidths argument you must set it as a
3562
- sequence of floats, as required by
3563
- `~matplotlib.collections.RegularPolyCollection`.
3564
+ If None, defaults to (lines.linewidth,).
3565
+
3566
+ edgecolors : color or sequence of color, optional, default: None
3567
+ If None, defaults to (patch.edgecolor).
3568
+ If 'face', the edge color will always be the same as
3569
+ the face color. If it is 'none', the patch boundary will not
3570
+ be drawn. For non-filled markers, the `edgecolors` kwarg
3571
+ is ignored; color is determined by `c`.
3564
3572
3565
3573
Returns
3566
3574
-------
@@ -3598,43 +3606,41 @@ def scatter(self, x, y, s=20, c='b', marker='o', cmap=None, norm=None,
3598
3606
3599
3607
s = np .ma .ravel (s ) # This doesn't have to match x, y in size.
3600
3608
3601
- c_is_stringy = is_string_like (c ) or is_sequence_of_strings (c )
3602
- if not c_is_stringy :
3603
- c = np .asanyarray (c )
3604
- if c .size == x .size :
3605
- c = np .ma .ravel (c )
3609
+ # After this block, c_array will be None unless
3610
+ # c is an array for mapping. The potential ambiguity
3611
+ # with a sequence of 3 or 4 numbers is resolved in
3612
+ # favor mapping, not rgb or rgba.
3613
+ try :
3614
+ c_array = np .asanyarray (c , dtype = float )
3615
+ if c_array .shape == x .shape :
3616
+ c = np .ma .ravel (c_array )
3617
+ else :
3618
+ # Wrong shape; it must not be intended for mapping.
3619
+ c_array = None
3620
+ except ValueError :
3621
+ # Failed to make a floating-point array; c must be color specs.
3622
+ c_array = None
3623
+
3624
+ if c_array is None :
3625
+ colors = c # must be acceptable as PathCollection facecolors
3626
+ else :
3627
+ colors = None # use cmap, norm after collection is created
3606
3628
3629
+ # c will be unchanged unless it is the same length as x:
3607
3630
x , y , s , c = cbook .delete_masked_points (x , y , s , c )
3608
3631
3609
3632
scales = s # Renamed for readability below.
3610
3633
3611
- if c_is_stringy :
3612
- colors = mcolors .colorConverter .to_rgba_array (c , alpha )
3613
- else :
3614
- # The inherent ambiguity is resolved in favor of color
3615
- # mapping, not interpretation as rgb or rgba:
3616
- if c .size == x .size :
3617
- colors = None # use cmap, norm after collection is created
3618
- else :
3619
- colors = mcolors .colorConverter .to_rgba_array (c , alpha )
3620
-
3621
- faceted = kwargs .pop ('faceted' , None )
3622
- edgecolors = kwargs .get ('edgecolors' , None )
3623
- if faceted is not None :
3624
- cbook .warn_deprecated (
3625
- '1.2' , name = 'faceted' , alternative = 'edgecolor' ,
3626
- obj_type = 'option' )
3627
- if faceted :
3628
- edgecolors = None
3629
- else :
3630
- edgecolors = 'none'
3631
-
3632
3634
# to be API compatible
3633
3635
if marker is None and not (verts is None ):
3634
3636
marker = (verts , 0 )
3635
3637
verts = None
3636
3638
3637
- marker_obj = mmarkers .MarkerStyle (marker )
3639
+ if isinstance (marker , mmarkers .MarkerStyle ):
3640
+ marker_obj = marker
3641
+ else :
3642
+ marker_obj = mmarkers .MarkerStyle (marker )
3643
+
3638
3644
path = marker_obj .get_path ().transformed (
3639
3645
marker_obj .get_transform ())
3640
3646
if not marker_obj .is_filled ():
@@ -3649,9 +3655,9 @@ def scatter(self, x, y, s=20, c='b', marker='o', cmap=None, norm=None,
3649
3655
linewidths = linewidths ,
3650
3656
offsets = offsets ,
3651
3657
transOffset = kwargs .pop ('transform' , self .transData ),
3658
+ alpha = alpha
3652
3659
)
3653
3660
collection .set_transform (mtransforms .IdentityTransform ())
3654
- collection .set_alpha (alpha )
3655
3661
collection .update (kwargs )
3656
3662
3657
3663
if colors is None :
0 commit comments