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

Skip to content
Prev Previous commit
Next Next commit
fix: add auto to _set_viewLim_intervalx
Fix error in previous commit.
  • Loading branch information
syrte committed Aug 3, 2016
commit d1459adee6a6f7192e3e6a071c850a527fad3b71
34 changes: 22 additions & 12 deletions lib/matplotlib/axes/_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -2857,21 +2857,26 @@ def set_xlim(self, left=None, right=None, emit=True, auto=False, **kw):
left, right = mtransforms.nonsingular(left, right, increasing=False)
left, right = self.xaxis.limit_range_for_scale(left, right)

if auto is not None:
self._autoscaleXon = bool(auto)

self._set_viewLim_intervalx(left, right, emit=emit)
self._set_viewLim_intervalx(left, right, emit=emit, auto=auto)
return left, right

def _set_viewLim_intervalx(self, left, right, emit=True):
def _set_viewLim_intervalx(self, left, right, emit=True, auto=None):
"""
Set the data limits for the xaxis
This should be the only method who can change viewLim.intervalx directly.

*emit*: [ *True* | *False* ]
Keyword arguments:
*emit*: [ *True* | *False* ]
Notify observers of limit change

*auto*: [ *True* | *False* | *None* ]
Turn *x* autoscaling on (*True*), off (*False*; default),
or leave unchanged (*None*)
"""
self.viewLim.intervalx = (left, right)
if auto is not None:
self._autoscaleXon = bool(auto)

if emit:
self.callbacks.process('xlim_changed', self)
# Call all of the other x-axes that are shared with this one
Expand Down Expand Up @@ -3126,21 +3131,26 @@ def set_ylim(self, bottom=None, top=None, emit=True, auto=False, **kw):
bottom, top = mtransforms.nonsingular(bottom, top, increasing=False)
bottom, top = self.yaxis.limit_range_for_scale(bottom, top)

if auto is not None:
self._autoscaleYon = bool(auto)

self._set_viewLim_intervaly(bottom, top, emit=emit)
self._set_viewLim_intervaly(bottom, top, emit=emit, auto=auto)
return bottom, top

def _set_viewLim_intervaly(self, bottom, top, emit=True):
def _set_viewLim_intervaly(self, bottom, top, emit=True, auto=None):
"""
Set the data limits for the yaxis
This should be the only method who can change viewLim.intervaly directly.

*emit*: [ *True* | *False* ]
Keyword arguments:
*emit*: [ *True* | *False* ]
Notify observers of limit change

*auto*: [ *True* | *False* | *None* ]
Turn *x* autoscaling on (*True*), off (*False*; default),
or leave unchanged (*None*)
"""
self.viewLim.intervaly = (bottom, top)
if auto is not None:
self._autoscaleYon = bool(auto)

if emit:
self.callbacks.process('ylim_changed', self)
# Call all of the other y-axes that are shared with this one
Expand Down