Skip to content

Commit ae4ab31

Browse files
committed
Always create a new subplot in plt.subplot()
1 parent ea68032 commit ae4ab31

File tree

1 file changed

+1
-20
lines changed

1 file changed

+1
-20
lines changed

lib/matplotlib/pyplot.py

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1156,15 +1156,6 @@ def subplot(*args, **kwargs):
11561156
If you do not want this behavior, use the `.Figure.add_subplot` method
11571157
or the `.pyplot.axes` function instead.
11581158
1159-
If the figure already has a subplot with key (*args*,
1160-
*kwargs*) then it will simply make that subplot current and
1161-
return it. This behavior is deprecated. Meanwhile, if you do
1162-
not want this behavior (i.e., you want to force the creation of a
1163-
new subplot), you must use a unique set of args and kwargs. The axes
1164-
*label* attribute has been exposed for this purpose: if you want
1165-
two subplots that are otherwise identical to be added to the figure,
1166-
make sure you give them unique labels.
1167-
11681159
In rare circumstances, `.Figure.add_subplot` may be called with a single
11691160
argument, a subplot axes instance already created in the
11701161
present figure but not in the figure's list of axes.
@@ -1221,17 +1212,7 @@ def subplot(*args, **kwargs):
12211212
"and/or 'nrows'. Did you intend to call subplots()?")
12221213

12231214
fig = gcf()
1224-
1225-
# First, search for an existing subplot with a matching spec.
1226-
key = SubplotSpec._from_subplot_args(fig, args)
1227-
ax = next(
1228-
(ax for ax in fig.axes
1229-
if hasattr(ax, 'get_subplotspec') and ax.get_subplotspec() == key),
1230-
None)
1231-
1232-
# If no existing axes match, then create a new one.
1233-
if ax is None:
1234-
ax = fig.add_subplot(*args, **kwargs)
1215+
ax = fig.add_subplot(*args, **kwargs)
12351216

12361217
bbox = ax.bbox
12371218
axes_to_delete = []

0 commit comments

Comments
 (0)