@@ -1072,10 +1072,10 @@ def cla():
1072
1072
@docstring .dedent_interpd
1073
1073
def subplot (* args , ** kwargs ):
1074
1074
"""
1075
- Add a subplot to the current figure.
1075
+ Add an Axes to the current figure or retrieve an existing Axes .
1076
1076
1077
- Wrapper of `.Figure.add_subplot` with a difference in
1078
- behavior explained in the notes section.
1077
+ This is a wrapper of `.Figure.add_subplot` which provides additional
1078
+ behavior when working with the implicit API (see the notes section) .
1079
1079
1080
1080
Call signatures::
1081
1081
@@ -1142,8 +1142,8 @@ def subplot(*args, **kwargs):
1142
1142
1143
1143
Notes
1144
1144
-----
1145
- Creating a subplot will delete any pre-existing subplot that overlaps
1146
- with it beyond sharing a boundary::
1145
+ Creating a new Axes will delete any pre-existing Axes that
1146
+ overlaps with it beyond sharing a boundary::
1147
1147
1148
1148
import matplotlib.pyplot as plt
1149
1149
# plot a line, implicitly creating a subplot(111)
@@ -1156,18 +1156,10 @@ def subplot(*args, **kwargs):
1156
1156
If you do not want this behavior, use the `.Figure.add_subplot` method
1157
1157
or the `.pyplot.axes` function instead.
1158
1158
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
-
1168
- In rare circumstances, `.Figure.add_subplot` may be called with a single
1169
- argument, a subplot axes instance already created in the
1170
- present figure but not in the figure's list of axes.
1159
+ If the current Figure already has an Axes created with the same
1160
+ (*args*, *kwargs*) the existing Axes will be made current and
1161
+ returned. If the values in *kwargs* are mutable this may not
1162
+ behave as expected.
1171
1163
1172
1164
See Also
1173
1165
--------
@@ -1183,10 +1175,10 @@ def subplot(*args, **kwargs):
1183
1175
plt.subplot(221)
1184
1176
1185
1177
# equivalent but more general
1186
- ax1= plt.subplot(2, 2, 1)
1178
+ ax1 = plt.subplot(2, 2, 1)
1187
1179
1188
1180
# add a subplot with no frame
1189
- ax2= plt.subplot(222, frameon=False)
1181
+ ax2 = plt.subplot(222, frameon=False)
1190
1182
1191
1183
# add a polar subplot
1192
1184
plt.subplot(223, projection='polar')
@@ -1199,6 +1191,10 @@ def subplot(*args, **kwargs):
1199
1191
1200
1192
# add ax2 to the figure again
1201
1193
plt.subplot(ax2)
1194
+
1195
+ # make the first axes "current" again
1196
+ plt.subplot(221)
1197
+
1202
1198
"""
1203
1199
1204
1200
# if subplot called without arguments, create subplot(1, 1, 1)
0 commit comments