我有四个图形和轴对象,我想将它们作为子图添加到新图形中。即如下代码: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) = ax1fig5.subplot(2, 2, 2) = ax2fig5.subplot(2, 2, 3) = ax3fig5.subplot(2, 2, 4) = ax4做这个的最好方式是什么?我正在使用 Matplotlib 版本 3.3.1。
1 回答
![?](http://img1.sycdn.imooc.com/533e564d0001308602000200-100-100.jpg)
慕容3067478
TA贡献1773条经验 获得超3个赞
你离我们并不遥远。您只需将其附加到新的即可。
fig5 = plt.figure()
fig5.axes.append(ax1) # ax2 etc
添加回答
举报
0/150
提交
取消