Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit c0b5013

Browse files
committed
Handle invalid positions regardless of the plotinvalid kwarg.
1 parent 0fb837a commit c0b5013

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

lib/matplotlib/axes/_axes.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4240,9 +4240,14 @@ def scatter(self, x, y, s=None, c=None, marker=None, cmap=None, norm=None,
42404240
else:
42414241
colors = None # use cmap, norm after collection is created
42424242

4243-
if plotinvalid is False:
4244-
# `delete_masked_points` only modifies arguments of the same length
4245-
# as `x`.
4243+
if plotinvalid and colors == None:
4244+
# Do full color mapping; don't remove invalid c entries.
4245+
ind = np.arange(len(c))
4246+
x, y, s, ind, colors, edgecolors, linewidths =\
4247+
cbook.delete_masked_points(
4248+
x, y, s, ind, colors, edgecolors, linewidths)
4249+
c = np.ma.masked_invalid(c[ind])
4250+
else:
42464251
x, y, s, c, colors, edgecolors, linewidths =\
42474252
cbook.delete_masked_points(
42484253
x, y, s, c, colors, edgecolors, linewidths)
@@ -4289,12 +4294,7 @@ def scatter(self, x, y, s=None, c=None, marker=None, cmap=None, norm=None,
42894294
if norm is not None and not isinstance(norm, mcolors.Normalize):
42904295
raise ValueError(
42914296
"'norm' must be an instance of 'mcolors.Normalize'")
4292-
4293-
if plotinvalid is False:
4294-
collection.set_array(c)
4295-
else:
4296-
collection.set_array(ma.masked_invalid(c))
4297-
4297+
collection.set_array(c)
42984298
collection.set_cmap(cmap)
42994299
collection.set_norm(norm)
43004300

0 commit comments

Comments
 (0)