Skip to content

Commit aafe0ef

Browse files
committed
Use ax.remove() in docs, not delaxes() -- the former is more general.
1 parent 358c651 commit aafe0ef

File tree

1 file changed

+8
-16
lines changed

1 file changed

+8
-16
lines changed

lib/matplotlib/figure.py

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1342,25 +1342,17 @@ def add_subplot(self, *args, **kwargs):
13421342
::
13431343
13441344
fig = plt.figure()
1345-
fig.add_subplot(221)
13461345
1347-
# equivalent but more general
1348-
ax1 = fig.add_subplot(2, 2, 1)
1346+
fig.add_subplot(231)
1347+
ax1 = fig.add_subplot(2, 3, 1) # equivalent but more general
13491348
1350-
# add a subplot with no frame
1351-
ax2 = fig.add_subplot(222, frameon=False)
1349+
fig.add_subplot(232, frameon=False) # subplot with no frame
1350+
fig.add_subplot(233, projection='polar') # polar subplot
1351+
fig.add_subplot(234, sharex=ax1) # subplot sharing x-axis with ax1
1352+
fig.add_subplot(235, facecolor="red") # red subplot
13521353
1353-
# add a polar subplot
1354-
fig.add_subplot(223, projection='polar')
1355-
1356-
# add a red subplot that share the x-axis with ax1
1357-
fig.add_subplot(224, sharex=ax1, facecolor='red')
1358-
1359-
# delete x2 from the figure
1360-
fig.delaxes(ax2)
1361-
1362-
# add x2 to the figure again
1363-
fig.add_subplot(ax2)
1354+
ax1.remove() # delete ax1 from the figure
1355+
fig.add_subplot(ax1) # add ax1 back to the figure
13641356
"""
13651357
if not len(args):
13661358
args = (1, 1, 1)

0 commit comments

Comments
 (0)