Skip to content

Simplify implementation of set_{x,y}bound. #14609

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 15, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 6 additions & 24 deletions lib/matplotlib/axes/_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -3082,7 +3082,7 @@ def set_xbound(self, lower=None, upper=None):
Set the lower and upper numerical bounds of the x-axis.

This method will honor axes inversion regardless of parameter order.
It will not change the autoscaling setting (``Axes._autoscaleXon``).
It will not change the autoscaling setting (`.get_autoscalex_on()`).

Parameters
----------
Expand All @@ -3100,22 +3100,13 @@ def set_xbound(self, lower=None, upper=None):
lower, upper = lower

old_lower, old_upper = self.get_xbound()

if lower is None:
lower = old_lower
if upper is None:
upper = old_upper

if self.xaxis_inverted():
if lower < upper:
self.set_xlim(upper, lower, auto=None)
else:
self.set_xlim(lower, upper, auto=None)
else:
if lower < upper:
self.set_xlim(lower, upper, auto=None)
else:
self.set_xlim(upper, lower, auto=None)
self.set_xlim(sorted((lower, upper), reverse=self.xaxis_inverted()),
auto=None)

def get_xlim(self):
"""
Expand Down Expand Up @@ -3480,7 +3471,7 @@ def set_ybound(self, lower=None, upper=None):
Set the lower and upper numerical bounds of the y-axis.

This method will honor axes inversion regardless of parameter order.
It will not change the autoscaling setting (``Axes._autoscaleYon``).
It will not change the autoscaling setting (`.get_autoscaley_on()`).

Parameters
----------
Expand All @@ -3498,22 +3489,13 @@ def set_ybound(self, lower=None, upper=None):
lower, upper = lower

old_lower, old_upper = self.get_ybound()

if lower is None:
lower = old_lower
if upper is None:
upper = old_upper

if self.yaxis_inverted():
if lower < upper:
self.set_ylim(upper, lower, auto=None)
else:
self.set_ylim(lower, upper, auto=None)
else:
if lower < upper:
self.set_ylim(lower, upper, auto=None)
else:
self.set_ylim(upper, lower, auto=None)
self.set_ylim(sorted((lower, upper), reverse=self.yaxis_inverted()),
auto=None)

def get_ylim(self):
"""
Expand Down
16 changes: 5 additions & 11 deletions lib/mpl_toolkits/mplot3d/axes3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -1464,30 +1464,24 @@ def get_zbound(self):
def set_zbound(self, lower=None, upper=None):
"""
Set the lower and upper numerical bounds of the z-axis.

This method will honor axes inversion regardless of parameter order.
It will not change the :attr:`_autoscaleZon` attribute.
It will not change the autoscaling setting (`.get_autoscalez_on()`).

.. versionadded :: 1.1.0
This function was added, but not tested. Please report any bugs.
"""
if upper is None and np.iterable(lower):
lower, upper = lower

old_lower, old_upper = self.get_zbound()
if lower is None:
lower = old_lower
if upper is None:
upper = old_upper

if self.zaxis_inverted():
if lower < upper:
self.set_zlim(upper, lower, auto=None)
else:
self.set_zlim(lower, upper, auto=None)
else:
if lower < upper:
self.set_zlim(lower, upper, auto=None)
else:
self.set_zlim(upper, lower, auto=None)
self.set_zlim(sorted((lower, upper), reverse=self.zaxis_inverted()),
auto=None)

def text(self, x, y, z, s, zdir=None, **kwargs):
'''
Expand Down
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy