Skip to content

Commit 6bcd43e

Browse files
authored
Merge pull request #13700 from meeseeksmachine/auto-backport-of-pr-13588-on-v3.1.x
Backport PR #13588 on branch v3.1.x (FIX: fallback to viewlims if no data)
2 parents 7277583 + 5e855ff commit 6bcd43e

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

lib/matplotlib/axes/_base.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2440,6 +2440,16 @@ def handle_single_axis(scale, autoscaleon, shared_axes, interval,
24402440
dl.extend(y_finite)
24412441

24422442
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
24432453
x0, x1 = getattr(bb, interval)
24442454
locator = axis.get_major_locator()
24452455
x0, x1 = locator.nonsingular(x0, x1)

lib/matplotlib/tests/test_axes.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6296,3 +6296,16 @@ def test_axis_bool_arguments(fig_test, fig_ref):
62966296
ax.axis(False)
62976297
ax.axis(True)
62986298
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

Comments
 (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