可以使用:fig.delaxes(图像对应的AxesSubplot)
删除想要删除的图像
示例代码
首先绘制一个示例图:
import matplotlib.pyplot as plt
fig, axes = plt.subplots(nrows=2, ncols=3)
for _a in range(2):
for _b in range(3):
axes[_a][_b].plot([_a,(_a+1)**2], [_b,(_b+1)**2])
得到结果:
![在这里插入图片描述](https://img-blog.csdnimg.cn/b45d8729a2f342bda222e708393b0b60.png)
然后运行代码:
fig.delaxes(axes[1][2])
得到结果:
![在这里插入图片描述](https://img-blog.csdnimg.cn/81ddeef4db394988ae37d21a0e7b7bf9.png)