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

Skip to content

Commit 80d7a86

Browse files
authored
Merge pull request #14848 from dstansby/axis-err-msg
Clearer error message for plt.axis()
2 parents 33376e9 + 5b5cb3e commit 80d7a86

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

lib/matplotlib/axes/_base.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1660,11 +1660,13 @@ def axis(self, *args, emit=True, **kwargs):
16601660
"3.2", message="Passing more than one positional "
16611661
"argument to axis() is deprecated and will raise a "
16621662
"TypeError %(removal)s.")
1663-
v = args[0]
1663+
limits = args[0]
16641664
try:
1665-
xmin, xmax, ymin, ymax = v
1666-
except ValueError:
1667-
raise ValueError('args must contain [xmin xmax ymin ymax]')
1665+
xmin, xmax, ymin, ymax = limits
1666+
except (TypeError, ValueError):
1667+
raise TypeError('the first argument to axis() must be an '
1668+
'interable of the form '
1669+
'[xmin, xmax, ymin, ymax]')
16681670
else:
16691671
xmin = kwargs.pop('xmin', None)
16701672
xmax = kwargs.pop('xmax', None)

0 commit comments

Comments
 (0)