@@ -4180,7 +4180,7 @@ def _parse_scatter_color_args(c, edgecolors, kwargs, xshape, yshape,
41804180 label_namer = "y" )
41814181 def scatter (self , x , y , s = None , c = None , marker = None , cmap = None , norm = None ,
41824182 vmin = None , vmax = None , alpha = None , linewidths = None ,
4183- verts = None , edgecolors = None ,
4183+ verts = None , edgecolors = None , * , plotnonfinite = False ,
41844184 ** kwargs ):
41854185 """
41864186 A scatter plot of *y* vs *x* with varying marker size and/or color.
@@ -4257,6 +4257,10 @@ def scatter(self, x, y, s=None, c=None, marker=None, cmap=None, norm=None,
42574257 For non-filled markers, the *edgecolors* kwarg is ignored and
42584258 forced to 'face' internally.
42594259
4260+ plotnonfinite : boolean, optional, default: False
4261+ Set to plot points with nonfinite *c*, in conjunction with
4262+ `~matplotlib.colors.Colormap.set_bad`.
4263+
42604264 Returns
42614265 -------
42624266 paths : `~matplotlib.collections.PathCollection`
@@ -4310,11 +4314,14 @@ def scatter(self, x, y, s=None, c=None, marker=None, cmap=None, norm=None,
43104314 c , edgecolors , kwargs , xshape , yshape ,
43114315 get_next_color_func = self ._get_patches_for_fill .get_next_color )
43124316
4313- # `delete_masked_points` only modifies arguments of the same length as
4314- # `x`.
4315- x , y , s , c , colors , edgecolors , linewidths = \
4316- cbook .delete_masked_points (
4317- x , y , s , c , colors , edgecolors , linewidths )
4317+ if plotnonfinite and colors is None :
4318+ c = np .ma .masked_invalid (c )
4319+ x , y , s , edgecolors , linewidths = \
4320+ cbook ._combine_masks (x , y , s , edgecolors , linewidths )
4321+ else :
4322+ x , y , s , c , colors , edgecolors , linewidths = \
4323+ cbook ._combine_masks (
4324+ x , y , s , c , colors , edgecolors , linewidths )
43184325
43194326 scales = s # Renamed for readability below.
43204327
@@ -4340,7 +4347,7 @@ def scatter(self, x, y, s=None, c=None, marker=None, cmap=None, norm=None,
43404347 edgecolors = 'face'
43414348 linewidths = rcParams ['lines.linewidth' ]
43424349
4343- offsets = np .column_stack ([x , y ])
4350+ offsets = np .ma . column_stack ([x , y ])
43444351
43454352 collection = mcoll .PathCollection (
43464353 (path ,), scales ,
@@ -4358,7 +4365,7 @@ def scatter(self, x, y, s=None, c=None, marker=None, cmap=None, norm=None,
43584365 if norm is not None and not isinstance (norm , mcolors .Normalize ):
43594366 raise ValueError (
43604367 "'norm' must be an instance of 'mcolors.Normalize'" )
4361- collection .set_array (np . asarray ( c ) )
4368+ collection .set_array (c )
43624369 collection .set_cmap (cmap )
43634370 collection .set_norm (norm )
43644371
0 commit comments