@@ -4010,7 +4010,7 @@ def dopatch(xs, ys, **kwargs):
4010
4010
label_namer = "y" )
4011
4011
def scatter (self , x , y , s = None , c = None , marker = None , cmap = None , norm = None ,
4012
4012
vmin = None , vmax = None , alpha = None , linewidths = None ,
4013
- verts = None , edgecolors = None ,
4013
+ verts = None , edgecolors = None , plotinvalid = False ,
4014
4014
** kwargs ):
4015
4015
"""
4016
4016
A scatter plot of *y* vs *x* with varying marker size and/or color.
@@ -4087,6 +4087,10 @@ def scatter(self, x, y, s=None, c=None, marker=None, cmap=None, norm=None,
4087
4087
For non-filled markers, the *edgecolors* kwarg is ignored and
4088
4088
forced to 'face' internally.
4089
4089
4090
+ plotinvalid : boolean, optional, default: False
4091
+ Set to plot valid points with invalid color, in conjunction with
4092
+ `~matplotlib.colors.Colormap.set_bad`.
4093
+
4090
4094
Returns
4091
4095
-------
4092
4096
paths : `~matplotlib.collections.PathCollection`
@@ -4236,11 +4240,12 @@ def scatter(self, x, y, s=None, c=None, marker=None, cmap=None, norm=None,
4236
4240
else :
4237
4241
colors = None # use cmap, norm after collection is created
4238
4242
4239
- # `delete_masked_points` only modifies arguments of the same length as
4240
- # `x`.
4241
- x , y , s , c , colors , edgecolors , linewidths = \
4242
- cbook .delete_masked_points (
4243
- x , y , s , c , colors , edgecolors , linewidths )
4243
+ if plotinvalid is False :
4244
+ # `delete_masked_points` only modifies arguments of the same length
4245
+ # as `x`.
4246
+ x , y , s , c , colors , edgecolors , linewidths = \
4247
+ cbook .delete_masked_points (
4248
+ x , y , s , c , colors , edgecolors , linewidths )
4244
4249
4245
4250
scales = s # Renamed for readability below.
4246
4251
@@ -4284,7 +4289,12 @@ def scatter(self, x, y, s=None, c=None, marker=None, cmap=None, norm=None,
4284
4289
if norm is not None and not isinstance (norm , mcolors .Normalize ):
4285
4290
raise ValueError (
4286
4291
"'norm' must be an instance of 'mcolors.Normalize'" )
4287
- collection .set_array (np .asarray (c ))
4292
+
4293
+ if plotinvalid is False :
4294
+ collection .set_array (c )
4295
+ else :
4296
+ collection .set_array (ma .masked_invalid (c ))
4297
+
4288
4298
collection .set_cmap (cmap )
4289
4299
collection .set_norm (norm )
4290
4300
0 commit comments