8000 FIX · matplotlib/matplotlib@b36b3f6 · GitHub
[go: up one dir, main page]

Skip to content

Commit b36b3f6

Browse files
committed
FIX
1 parent 93142c6 commit b36b3f6

File tree

1 file changed

+14
-35
lines changed

1 file changed

+14
-35
lines changed

lib/matplotlib/figure.py

Lines changed: 14 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,6 @@ def show(self, warn=True):
384384
AttributeError.
385385
386386
.. warning::
387-
388387
This does not manage an GUI event loop. Consequently, the figure
389388
may only be shown briefly or not shown at all if you or your
390389
environment are not managing an event loop.
@@ -1265,16 +1264,13 @@ def add_subplot(self, *args, **kwargs):
12651264
12661265
Parameters
12671266
----------
1268-
*args : int, (int, int, *index*), or `SubplotSpec`, default: (1, 1, 1)
1267+
*args, int or (int, int, int) or `SubplotSpec`, default: (1, 1, 1)
12691268
The position of the subplot described by one of
12701269
12711270
- Three integers (*nrows*, *ncols*, *index*). The subplot will
12721271
take the *index* position on a grid with *nrows* rows and
12731272
*ncols* columns. *index* starts at 1 in the upper left corner
1274-
and increases to the right. *index* can also be a two-tuple
1275-
specifying the (*start*, *stop*) indices of the subplot, i.e.,
1276-
``fig.add_subplot(3, 1, (1, 2))`` makes a subplot that spans the
1277-
upper 2/3 of the figure.
1273+
and increases to the right.
12781274
- A 3-digit integer. The digits are interpreted as if given
12791275
separately as three single-digit integers, i.e.
12801276
``fig.add_subplot(235)`` is the same as
@@ -1381,26 +1377,14 @@ def add_subplot(self, *args, **kwargs):
13811377
raise TypeError('Positional arguments are not a valid '
13821378
'position specification.')
13831379
elif nargs == 3:
1384-
newarg = [None] * 3
1385-
message = ("Passing non-integers as three-element "
1386-
"position specification is deprecated since "
1387-
"%(since)s and will be removed %(removal)s.")
1388-
for nn, arg in enumerate(args[:2]):
1380+
for arg in args:
13891381
if not isinstance(arg, Integral):
1390-
cbook.warn_deprecated("3.3", message=message)
1391-
newarg[nn] = int(arg)
1392-
args2 = args[2]
1393-
if isinstance(args[2], tuple) and len(args[2]) == 2:
1394-
# start/stop two-tuple is allowed...
1395-
for arg in args[2]:
1396-
if not isinstance(arg, Integral):
1397-
cbook.warn_deprecated("3.3", message=message)
1398-
newarg[2] = (int(args[2][0]), int(args[2][1]))
1399-
else:
1400-
if not isinstance(args[2], Integral):
1401-
cbook.warn_deprecated("3.3", message=message)
1402-
newarg[2] = int(args[2])
1403-
args = tuple(newarg)
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))
14041388
else:
14051389
raise TypeError(f'add_subplot() takes 1 or 3 positional arguments '
14061390
f'but {nargs} were given')
@@ -1413,19 +1397,13 @@ def add_subplot(self, *args, **kwargs):
14131397
# make a key for the subplot (which includes the axes object id
14141398
# in the hash)
14151399
key = self._make_key(*args, **kwargs)
1416-
14171400
else:
1418-
if not args:
1419-
args = (1, 1, 1)
1420-
# Normalize correct ijk values to (i, j, k) here so that
1421-
# add_subplot(111) == add_subplot(1, 1, 1). Invalid values will
1422-
# trigger errors later (via SubplotSpec._from_subplot_args).
1423-
if (len(args) == 1 and isinstance(args[0], Integral)
1424-
and 100 <= args[0] <= 999):
1425-
args = tuple(map(int, str(args[0])))
14261401
projection_class, kwargs, key = \
14271402
self._process_projection_requirements(*args, **kwargs)
1428-
ax = self._axstack.get(key) # search axes with this key in stack
1403+
1404+
# try to find the axes with this key in the stack
1405+
ax = self._axstack.get(key)
1406+
14291407
if ax is not None:
14301408
if isinstance(ax, projection_class):
14311409
# the axes already existed, so set it as active & return
@@ -1438,6 +1416,7 @@ def add_subplot(self, *args, **kwargs):
14381416
# Without this, add_subplot would be simpler and
14391417
# more similar to add_axes.
14401418
self._axstack.remove(ax)
1419+
14411420
ax = subplot_class_factory(projection_class)(self, *args, **kwargs)
14421421

14431422
return self._add_axes_internal(key, ax)

0 commit comments

Comments
 (0)
0