Skip to content

Commit 76ff8d0

Browse files
authored
Merge pull request #14485 from dstansby/14429-backport
Backport #14429 on v3.1.x
2 parents 2bd61a6 + e221ffe commit 76ff8d0

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

lib/matplotlib/tests/test_units.py

+11
Original file line numberDiff line numberDiff line change
@@ -155,3 +155,14 @@ def test_jpl_barh_units():
155155
def test_empty_arrays():
156156
# Check that plotting an empty array with a dtype works
157157
plt.scatter(np.array([], dtype='datetime64[ns]'), np.array([]))
158+
159+
160+
def test_scatter_element0_masked():
161+
162+
times = np.arange('2005-02', '2005-03', dtype='datetime64[D]')
163+
164+
y = np.arange(len(times), dtype='float')
165+
y[0] = np.nan
166+
fig, ax = plt.subplots()
167+
ax.scatter(times, y)
168+
fig.canvas.draw()

lib/matplotlib/units.py

+3
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ def default_units(x, axis):
4545
from numbers import Number
4646

4747
import numpy as np
48+
from numpy import ma
4849

4950
from matplotlib import cbook
5051

@@ -128,6 +129,8 @@ def is_numlike(x):
128129
"""
129130
if np.iterable(x):
130131
for thisx in x:
132+
if thisx is ma.masked:
133+
continue
131134
return isinstance(thisx, Number)
132135
else:
133136
return isinstance(x, Number)

0 commit comments

Comments
 (0)