There was an error while loading. Please reload this page.
2 parents 7277583 + 5e855ff commit 6bcd43eCopy full SHA for 6bcd43e
2 files changed
lib/matplotlib/axes/_base.py
@@ -2440,6 +2440,16 @@ def handle_single_axis(scale, autoscaleon, shared_axes, interval,
2440
dl.extend(y_finite)
2441
2442
bb = mtransforms.BboxBase.union(dl)
2443
+ # fall back on the viewlimits if this is not finite:
2444
+ vl = None
2445
+ if not np.isfinite(bb.intervalx).all():
2446
+ vl = mtransforms.BboxBase.union([ax.viewLim for ax in shared])
2447
+ bb.intervalx = vl.intervalx
2448
+ if not np.isfinite(bb.intervaly).all():
2449
+ if vl is None:
2450
+ vl = mtransforms.BboxBase.union(
2451
+ [ax.viewLim for ax in shared])
2452
+ bb.intervaly = vl.intervaly
2453
x0, x1 = getattr(bb, interval)
2454
locator = axis.get_major_locator()
2455
x0, x1 = locator.nonsingular(x0, x1)
lib/matplotlib/tests/test_axes.py
@@ -6296,3 +6296,16 @@ def test_axis_bool_arguments(fig_test, fig_ref):
6296
ax.axis(False)
6297
ax.axis(True)
6298
fig_ref.add_subplot(212).axis("on")
6299
+
6300
6301
+def test_datetime_masked():
6302
+ # make sure that all-masked data falls back to the viewlim
6303
+ # set in convert.axisinfo....
6304
+ x = np.array([datetime.datetime(2017, 1, n) for n in range(1, 6)])
6305
+ y = np.array([1, 2, 3, 4, 5])
6306
+ m = np.ma.masked_greater(y, 0)
6307
6308
+ fig, ax = plt.subplots()
6309
+ ax.plot(x, m)
6310
+ # these are the default viewlim
6311
+ assert ax.get_xlim() == (730120.0, 733773.0)
0 commit comments