我有四个图形和轴对象,我想将它们作为子图添加到新图形中。即如下代码:
fig1, ax1 = plt.subplots(1, 1, num=1)
ax1.plot(x1, y1)
fig2, ax2 = plt.subplots(1, 1, num=2)
ax2.plot(x2, y2)
fig3, ax3 = plt.subplots(1, 1, num=3)
ax3.plot(x3, y3)
fig4, ax4 = plt.subplots(1, 1, num=4)
ax4.plot(x4, y4)
我希望所有的ax1都是ax4新图中的子图fig5,如下所示:(这不是有效的代码,仅用于说明目的)
fig5 = plt.figure()
fig5.subplot(2, 2, 1) = ax1
fig5.subplot(2, 2, 2) = ax2
fig5.subplot(2, 2, 3) = ax3
fig5.subplot(2, 2, 4) = ax4
做这个的最好方式是什么?
我正在使用 Matplotlib 版本 3.3.1。
慕容3067478
相关分类