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

Skip to content

Commit 8d9cc12

Browse files
committed
Deprecate axis('normal') in favor of axis('auto').
This has been deprecated in docstrings since 2006 (d4e54a9, in `set_aspect`), even before the `axis()` was introduced (2e2f850). Support for `set_aspect('normal')` has already been removed.
1 parent 52047a0 commit 8d9cc12

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Passing 'normal' to `Axes.axis()` is deprecated
2+
```````````````````````````````````````````````
3+
4+
Use ``axis('auto')`` instead.

lib/matplotlib/axes/_base.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1263,7 +1263,8 @@ def set_aspect(self, aspect, adjustable=None, anchor=None, share=False):
12631263
matplotlib.axes.Axes.set_anchor
12641264
defining the position in case of extra space.
12651265
"""
1266-
if not (isinstance(aspect, str) and aspect in ('equal', 'auto')):
1266+
if not (cbook._str_equal(aspect, 'equal')
1267+
or cbook._str_equal(aspect, 'auto')):
12671268
aspect = float(aspect) # raise ValueError if necessary
12681269
if share:
12691270
axes = set(self._shared_x_axes.get_siblings(self)
@@ -1645,6 +1646,10 @@ def axis(self, *v, **kwargs):
16451646
self.set_axis_off()
16461647
elif s in ('equal', 'tight', 'scaled', 'normal',
16471648
'auto', 'image', 'square'):
1649+
if s == 'normal':
1650+
cbook.warn_deprecated(
1651+
"3.1", "Passing 'normal' to axis() is deprecated "
1652+
"since %(version)s; use 'auto' instead.")
16481653
self.set_autoscale_on(True)
16491654
self.set_aspect('auto')
16501655
self.autoscale_view(tight=False)

0 commit comments

Comments
 (0)