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

Skip to content

Commit 0cc213b

Browse files
committed
Fix bug in axis(): if called with no args or kwargs, don't change autoscale.
Bug reported by Joe Kington.
1 parent ffd4581 commit 0cc213b

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

lib/matplotlib/axes.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1239,11 +1239,17 @@ def apply_aspect(self, position=None):
12391239
def axis(self, *v, **kwargs):
12401240
'''
12411241
Convenience method for manipulating the x and y view limits
1242-
and the aspect ratio of the plot.
1242+
and the aspect ratio of the plot. For details, see
1243+
:func:`~matplotlib.pyplot.axis`.
12431244
12441245
*kwargs* are passed on to :meth:`set_xlim` and
12451246
:meth:`set_ylim`
12461247
'''
1248+
if len(v) == 0 and len(kwargs) == 0:
1249+
xmin, xmax = self.get_xlim()
1250+
ymin, ymax = self.get_ylim()
1251+
return xmin, xmax, ymin, ymax
1252+
12471253
if len(v)==1 and is_string_like(v[0]):
12481254
s = v[0].lower()
12491255
if s=='on': self.set_axis_on()
@@ -1289,7 +1295,6 @@ def axis(self, *v, **kwargs):
12891295
if len(v) != 4:
12901296
raise ValueError('v must contain [xmin xmax ymin ymax]')
12911297

1292-
12931298
self.set_xlim([v[0], v[1]])
12941299
self.set_ylim([v[2], v[3]])
12951300

0 commit comments

Comments
 (0)