Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 87fb687

Browse files
authored
Merge pull request #11537 from dstansby/non-finite-margins
MNT: Fix invalid value warning when autoscaling with no data limits
2 parents 0aa7a24 + ff1cee3 commit 87fb687

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

lib/matplotlib/axes/_base.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2429,7 +2429,13 @@ def handle_single_axis(scale, autoscaleon, shared_axes, interval,
24292429
do_upper_margin = not np.any(np.isclose(x1, stickies))
24302430
x0, x1 = axis._scale.limit_range_for_scale(x0, x1, minpos)
24312431
x0t, x1t = transform.transform([x0, x1])
2432-
delta = (x1t - x0t) * margin
2432+
2433+
if (np.isfinite(x1t) and np.isfinite(x0t)):
2434+
delta = (x1t - x0t) * margin
2435+
else:
2436+
# If at least one bound isn't finite, set margin to zero
2437+
delta = 0
2438+
24332439
if do_lower_margin:
24342440
x0t -= delta
24352441
if do_upper_margin:

0 commit comments

Comments
 (0)