Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 5e855ff

Browse filesBrowse files
efiringMeeseeksDev[bot]
authored andcommitted
Backport PR #13588: FIX: fallback to viewlims if no data
1 parent 5ca5e22 commit 5e855ff
Copy full SHA for 5e855ff

File tree

Expand file treeCollapse file tree

2 files changed

+23
-0
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+23
-0
lines changed

‎lib/matplotlib/axes/_base.py

Copy file name to clipboardExpand all lines: lib/matplotlib/axes/_base.py
+10Lines 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

Copy file name to clipboardExpand all lines: lib/matplotlib/tests/test_axes.py
+13Lines 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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.