Skip to content

Commit 268e955

Browse files
committed
Allow invalid limits when panning.
1 parent 48be964 commit 268e955

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

lib/matplotlib/axes/_base.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2822,6 +2822,7 @@ def _set_lim(self, axis, low, high, low_name, high_name,
28222822
"""Helper factoring the functionality of `get_{x,y,z}lim`."""
28232823
# Perhaps we can use axis.{get,set}_view_interval()... but zaxis seems
28242824
# to behave differently.
2825+
_called_from_pan = kw.pop("_called_from_pan", False)
28252826
if kw:
28262827
raise ValueError("Unrecognized kwargs: {}".format(kw))
28272828
axis_name = axis.axis_name
@@ -2835,7 +2836,8 @@ def _set_lim(self, axis, low, high, low_name, high_name,
28352836
self._process_unit_info(**{"{}data".format(axis_name): [low, high]})
28362837
low, high = map(axis.convert_units, [low, high])
28372838
for limit in [low, high]:
2838-
if not np.isreal(limit) or not np.isfinite(limit):
2839+
if not (_called_from_pan or
2840+
np.isreal(limit) and np.isfinite(limit)):
28392841
raise ValueError(
28402842
"Axis limits must be (or convert to) finite reals")
28412843
if low == high:
@@ -3774,8 +3776,8 @@ def format_deltas(key, dx, dy):
37743776
warnings.warn('Overflow while panning')
37753777
return
37763778

3777-
self.set_xlim(*result.intervalx)
3778-
self.set_ylim(*result.intervaly)
3779+
self.set_xlim(*result.intervalx, _called_from_pan=True)
3780+
self.set_ylim(*result.intervaly, _called_from_pan=True)
37793781

37803782
@cbook.deprecated("2.1")
37813783
def get_cursor_props(self):

0 commit comments

Comments
 (0)