diff --git a/lib/matplotlib/axes/_base.py b/lib/matplotlib/axes/_base.py index f994a9812d71..213eb633fdcd 100644 --- a/lib/matplotlib/axes/_base.py +++ b/lib/matplotlib/axes/_base.py @@ -2439,6 +2439,16 @@ def handle_single_axis(scale, autoscaleon, shared_axes, interval, dl.extend(y_finite) bb = mtransforms.BboxBase.union(dl) + # fall back on the viewlimits if this is not finite: + vl = None + if not np.isfinite(bb.intervalx).all(): + vl = mtransforms.BboxBase.union([ax.viewLim for ax in shared]) + bb.intervalx = vl.intervalx + if not np.isfinite(bb.intervaly).all(): + if vl is None: + vl = mtransforms.BboxBase.union( + [ax.viewLim for ax in shared]) + bb.intervaly = vl.intervaly x0, x1 = getattr(bb, interval) locator = axis.get_major_locator() x0, x1 = locator.nonsingular(x0, x1) diff --git a/lib/matplotlib/tests/test_axes.py b/lib/matplotlib/tests/test_axes.py index 45384d6b30fa..892a5168459e 100644 --- a/lib/matplotlib/tests/test_axes.py +++ b/lib/matplotlib/tests/test_axes.py @@ -6281,3 +6281,16 @@ def test_axis_bool_arguments(fig_test, fig_ref): ax.axis(False) ax.axis(True) fig_ref.add_subplot(212).axis("on") + + +def test_datetime_masked(): + # make sure that all-masked data falls back to the viewlim + # set in convert.axisinfo.... + x = np.array([datetime.datetime(2017, 1, n) for n in range(1, 6)]) + y = np.array([1, 2, 3, 4, 5]) + m = np.ma.masked_greater(y, 0) + + fig, ax = plt.subplots() + ax.plot(x, m) + # these are the default viewlim + assert ax.get_xlim() == (730120.0, 733773.0) pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy