There was an error while loading. Please reload this page.
1 parent 7875bc5 commit 5c2d2f3Copy full SHA for 5c2d2f3
2 files changed
lib/matplotlib/axes/_base.py
@@ -2430,6 +2430,16 @@ def handle_single_axis(scale, autoscaleon, shared_axes, interval,
2430
dl.extend(y_finite)
2431
2432
bb = mtransforms.BboxBase.union(dl)
2433
+ # fall back on the viewlimits if this is not finite:
2434
+ vl = None
2435
+ if not np.isfinite(bb.intervalx).all():
2436
+ vl = mtransforms.BboxBase.union([ax.viewLim for ax in shared])
2437
+ bb.intervalx = vl.intervalx
2438
+ if not np.isfinite(bb.intervaly).all():
2439
+ if vl is None:
2440
+ vl = mtransforms.BboxBase.union(
2441
+ [ax.viewLim for ax in shared])
2442
+ bb.intervaly = vl.intervaly
2443
x0, x1 = getattr(bb, interval)
2444
locator = axis.get_major_locator()
2445
x0, x1 = locator.nonsingular(x0, x1)
lib/matplotlib/tests/test_axes.py
@@ -6270,3 +6270,17 @@ def test_minor_accountedfor():
6270
targetbb = mtransforms.Bbox.from_bounds(*targets[n])
6271
assert_allclose(bbspines[n * 2].bounds, targetbb.bounds,
6272
atol=1e-2)
6273
+
6274
6275
+def test_datetime_masked():
6276
+ # make sure that all-masked data falls back to the viewlim
6277
+ # set in convert.axisinfo....
6278
+ x = np.array([datetime.datetime(2017, 1, n) for n in range(1, 6)])
6279
+ y = np.array([1,2,3,4,5])
6280
+ m = np.ma.masked_greater(y, 0)
6281
6282
+ fig = plt.figure()
6283
+ ax = fig.add_subplot(111)
6284
+ ax.plot(x, m)
6285
+ # these are the default viewlim
6286
+ assert ax.get_xlim() == (730120.0, 733773.0)
0 commit comments