8000 FIX: allow start-stop subplot · matplotlib/matplotlib@2d4a162 · GitHub
[go: up one dir, main page]

Skip to content

Commit 2d4a162

Browse files
committed
FIX: allow start-stop subplot
1 parent f843ffd commit 2d4a162

File tree

1 file changed

+17
-7
lines changed

1 file changed

+17
-7
lines changed

lib/matplotlib/figure.py

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1377,14 +1377,24 @@ def add_subplot(self, *args, **kwargs):
13771377
raise TypeError('Positional arguments are not a valid '
13781378
'position specification.')
13791379
elif nargs == 3:
1380-
for arg in args:
1380+
newarg = [None] * 3
1381+
message=("Passing non-integers as three-element "
1382+
"position specification is deprecated since "
1383+
"%(since)s and will be removed %(removal)s.")
1384+
for nn, arg in enumerate(args[:2]):
13811385
if not isinstance(arg, Integral):
1382-
cbook.warn_deprecated(
1383-
"3.3",
1384-
message="Passing non-integers as three-element "
1385-
"position specification is deprecated since "
1386-
"%(since)s and will be removed %(removal)s.")
1387-
args = tuple(map(int, args))
1386+
cbook.warn_deprecated("3.3", message)
1387+
newarg[nn] = int(arg)
1388+
if isinstance(args[2], tuple):
1389+
# start/stop two-tuple is allowed...
1390+
for arg in args[2]:
1391+
if not isinstance(arg, Integral):
1392+
cbook.warn_deprecated("3.3", message)
1393+
newarg[nn] = (int(args[0]), int(args[1]))
1394+
else:
1395+
newarg[nn] = int(arg)
1396+
arg = tuple(newarg)
1397+
13881398
else:
13891399
raise TypeError(f'add_subplot() takes 1 or 3 positional arguments '
13901400
f'but {nargs} were given')

0 commit comments

Comments
 (0)
0