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

Skip to content

Commit f374d08

Browse files
author
Vedant Nanda
committed
changed function name and docstring, fixed set_ylim3d()
1 parent c6e151f commit f374d08

File tree

2 files changed

+22
-16
lines changed

2 files changed

+22
-16
lines changed

lib/matplotlib/axes/_base.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2810,9 +2810,15 @@ def get_xlim(self):
28102810
"""
28112811
return tuple(self.viewLim.intervalx)
28122812

2813-
def _validate_axis_limits(self, limit, convert):
2813+
def _validate_converted_limits(self, limit, convert):
28142814
"""
2815-
Raise ValueError if specified axis limits are infinite.
2815+
Raise ValueError if converted limits are non-finite.
2816+
2817+
Note that this functions also accepts None as a limit argument.
2818+
2819+
Returns
2820+
-------
2821+
The limit value after call to convert(), or None if limit is None.
28162822
28172823
"""
28182824
if limit is not None:
@@ -2889,8 +2895,8 @@ def set_xlim(self, left=None, right=None, emit=True, auto=False, **kw):
28892895
left, right = left
28902896

28912897
self._process_unit_info(xdata=(left, right))
2892-
left = self._validate_axis_limits(left, self.convert_xunits)
2893-
right = self._validate_axis_limits(right, self.convert_xunits)
2898+
left = self._validate_converted_limits(left, self.convert_xunits)
2899+
right = self._validate_converted_limits(right, self.convert_xunits)
28942900

28952901
old_left, old_right = self.get_xlim()
28962902
if left is None:
@@ -3181,8 +3187,8 @@ def set_ylim(self, bottom=None, top=None, emit=True, auto=False, **kw):
31813187
if top is None and iterable(bottom):
31823188
bottom, top = bottom
31833189

3184-
bottom = self._validate_axis_limits(bottom, self.convert_yunits)
3185-
top = self._validate_axis_limits(top, self.convert_yunits)
3190+
bottom = self._validate_converted_limits(bottom, self.convert_yunits)
3191+
top = self._validate_converted_limits(top, self.convert_yunits)
31863192

31873193
old_bottom, old_top = self.get_ylim()
31883194

lib/mpl_toolkits/mplot3d/axes3d.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -605,8 +605,8 @@ def set_xlim3d(self, left=None, right=None, emit=True, auto=False, **kw):
605605
left, right = left
606606

607607
self._process_unit_info(xdata=(left, right))
608-
left = self._validate_axis_limits(left, self.convert_xunits)
609-
right = self._validate_axis_limits(right, self.convert_xunits)
608+
left = self._validate_converted_limits(left, self.convert_xunits)
609+
right = self._validate_converted_limits(right, self.convert_xunits)
610610

611611
old_left, old_right = self.get_xlim()
612612
if left is None:
@@ -657,14 +657,14 @@ def set_ylim3d(self, bottom=None, top=None, emit=True, auto=False, **kw):
657657
bottom, top = bottom
658658

659659
self._process_unit_info(ydata=(bottom, top))
660-
if bottom is not None:
661-
bottom = self.convert_yunits(bottom)
662-
if top is not None:
663-
top = self.convert_yunits(top)
660+
bottom = self._validate_converted_limits(bottom, self.convert_yunits)
661+
top = self._validate_converted_limits(top, self.convert_yunits)
664662

665663
old_bottom, old_top = self.get_ylim()
666-
bottom = self._validate_axis_limits(bottom, self.convert_yunits)
667-
top = self._validate_axis_limits(top, self.convert_yunits)
664+
if bottom is None:
665+
bottom = old_bottom
666+
if top is None:
667+
top = old_top
668668

669669
if top == bottom:
670670
warnings.warn(('Attempting to set identical bottom==top results\n'
@@ -709,8 +709,8 @@ def set_zlim3d(self, bottom=None, top=None, emit=True, auto=False, **kw):
709709
bottom, top = bottom
710710

711711
self._process_unit_info(zdata=(bottom, top))
712-
bottom = self._validate_axis_limits(bottom, self.convert_yunits)
713-
top = self._validate_axis_limits(top, self.convert_yunits)
712+
bottom = self._validate_converted_limits(bottom, self.convert_yunits)
713+
top = self._validate_converted_limits(top, self.convert_yunits)
714714

715715
old_bottom, old_top = self.get_zlim()
716716
if bottom is None:

0 commit comments

Comments
 (0)