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 a60ac1a

Browse filesBrowse files
committed
Simplify implementation of set_{x,y}bound.
... and don't refer to a private attribute in the docstring.
1 parent 121fbfc commit a60ac1a
Copy full SHA for a60ac1a

File tree

Expand file treeCollapse file tree

2 files changed

+11
-35
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+11
-35
lines changed

‎lib/matplotlib/axes/_base.py

Copy file name to clipboardExpand all lines: lib/matplotlib/axes/_base.py
+6-24Lines changed: 6 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -3082,7 +3082,7 @@ def set_xbound(self, lower=None, upper=None):
30823082
Set the lower and upper numerical bounds of the x-axis.
30833083
30843084
This method will honor axes inversion regardless of parameter order.
3085-
It will not change the autoscaling setting (``Axes._autoscaleXon``).
3085+
It will not change the autoscaling setting (`.get_autoscalex_on()`).
30863086
30873087
Parameters
30883088
----------
@@ -3100,22 +3100,13 @@ def set_xbound(self, lower=None, upper=None):
31003100
lower, upper = lower
31013101

31023102
old_lower, old_upper = self.get_xbound()
3103-
31043103
if lower is None:
31053104
lower = old_lower
31063105
if upper is None:
31073106
upper = old_upper
31083107

3109-
if self.xaxis_inverted():
3110-
if lower < upper:
3111-
self.set_xlim(upper, lower, auto=None)
3112-
else:
3113-
self.set_xlim(lower, upper, auto=None)
3114-
else:
3115-
if lower < upper:
3116-
self.set_xlim(lower, upper, auto=None)
3117-
else:
3118-
self.set_xlim(upper, lower, auto=None)
3108+
self.set_xlim(sorted((lower, upper), reverse=self.xaxis_inverted()),
3109+
auto=None)
31193110

31203111
def get_xlim(self):
31213112
"""
@@ -3480,7 +3471,7 @@ def set_ybound(self, lower=None, upper=None):
34803471
Set the lower and upper numerical bounds of the y-axis.
34813472
34823473
This method will honor axes inversion regardless of parameter order.
3483-
It will not change the autoscaling setting (``Axes._autoscaleYon``).
3474+
It will not change the autoscaling setting (`.get_autoscaley_on()`).
34843475
34853476
Parameters
34863477
----------
@@ -3498,22 +3489,13 @@ def set_ybound(self, lower=None, upper=None):
34983489
lower, upper = lower
34993490

35003491
old_lower, old_upper = self.get_ybound()
3501-
35023492
if lower is None:
35033493
lower = old_lower
35043494
if upper is None:
35053495
upper = old_upper
35063496

3507-
if self.yaxis_inverted():
3508-
if lower < upper:
3509-
self.set_ylim(upper, lower, auto=None)
3510-
else:
3511-
self.set_ylim(lower, upper, auto=None)
3512-
else:
3513-
if lower < upper:
3514-
self.set_ylim(lower, upper, auto=None)
3515-
else:
3516-
self.set_ylim(upper, lower, auto=None)
3497+
self.set_ylim(sorted((lower, upper), reverse=self.yaxis_inverted()),
3498+
auto=None)
35173499

35183500
def get_ylim(self):
35193501
"""

‎lib/mpl_toolkits/mplot3d/axes3d.py

Copy file name to clipboardExpand all lines: lib/mpl_toolkits/mplot3d/axes3d.py
+5-11Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1464,30 +1464,24 @@ def get_zbound(self):
14641464
def set_zbound(self, lower=None, upper=None):
14651465
"""
14661466
Set the lower and upper numerical bounds of the z-axis.
1467+
14671468
This method will honor axes inversion regardless of parameter order.
1468-
It will not change the :attr:`_autoscaleZon` attribute.
1469+
It will not change the autoscaling setting (`.get_autoscalez_on()`).
14691470
14701471
.. versionadded :: 1.1.0
14711472
This function was added, but not tested. Please report any bugs.
14721473
"""
14731474
if upper is None and np.iterable(lower):
14741475
lower, upper = lower
1476+
14751477
old_lower, old_upper = self.get_zbound()
14761478
if lower is None:
14771479
lower = old_lower
14781480
if upper is None:
14791481
upper = old_upper
14801482

1481-
if self.zaxis_inverted():
1482-
if lower < upper:
1483-
self.set_zlim(upper, lower, auto=None)
1484-
else:
1485-
self.set_zlim(lower, upper, auto=None)
1486-
else:
1487-
if lower < upper:
1488-
self.set_zlim(lower, upper, auto=None)
1489-
else:
1490-
self.set_zlim(upper, lower, auto=None)
1483+
self.set_zlim(sorted((lower, upper), reverse=self.zaxis_inverted()),
1484+
auto=None)
14911485

14921486
def text(self, x, y, z, s, zdir=None, **kwargs):
14931487
'''

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.