diff --git a/lib/matplotlib/axes/_base.py b/lib/matplotlib/axes/_base.py index 6a20b99be069..6ad721561b8e 100644 --- a/lib/matplotlib/axes/_base.py +++ b/lib/matplotlib/axes/_base.py @@ -3264,11 +3264,10 @@ def set_xlim(self, left=None, right=None, emit=True, auto=False, cbook._warn_external( f"Attempting to set identical left == right == {left} results " f"in singular transformations; automatically expanding.") - swapped = left > right + reverse = left > right left, right = self.xaxis.get_major_locator().nonsingular(left, right) left, right = self.xaxis.limit_range_for_scale(left, right) - if swapped: - left, right = right, left + left, right = sorted([left, right], reverse=reverse) self.viewLim.intervalx = (left, right) if auto is not None: @@ -3647,11 +3646,10 @@ def set_ylim(self, bottom=None, top=None, emit=True, auto=False, f"Attempting to set identical bottom == top == {bottom} " f"results in singular transformations; automatically " f"expanding.") - swapped = bottom > top + reverse = bottom > top bottom, top = self.yaxis.get_major_locator().nonsingular(bottom, top) bottom, top = self.yaxis.limit_range_for_scale(bottom, top) - if swapped: - bottom, top = top, bottom + bottom, top = sorted([bottom, top], reverse=reverse) self.viewLim.intervaly = (bottom, top) if auto is not None: diff --git a/lib/mpl_toolkits/mplot3d/axes3d.py b/lib/mpl_toolkits/mplot3d/axes3d.py index f6dff2bb939c..4202be9a1138 100644 --- a/lib/mpl_toolkits/mplot3d/axes3d.py +++ b/lib/mpl_toolkits/mplot3d/axes3d.py @@ -623,11 +623,10 @@ def set_xlim3d(self, left=None, right=None, emit=True, auto=False, cbook._warn_external( f"Attempting to set identical left == right == {left} results " f"in singular transformations; automatically expanding.") - swapped = left > right + reverse = left > right left, right = self.xaxis.get_major_locator().nonsingular(left, right) left, right = self.xaxis.limit_range_for_scale(left, right) - if swapped: - left, right = right, left + left, right = sorted([left, right], reverse=reverse) self.xy_viewLim.intervalx = (left, right) if auto is not None: