只需使用子图.
plt.plot(data1)
plt.show()
plt.subplot(1,2,1)
plt.plot(data2)
plt.subplot(1,2,2)
plt.plot(data3)
plt.show()
(这段代码不起作用,重要的是它背后的想法)
对于2号,同样的事情:使用子图:
# 1. Plot in same line, this would work
fig = plt.figure(figsize = (15,8))
ax1 = fig.add_subplot(1,2,1, projection = '3d')
custom_plot1(ax1)
ax2 = fig.add_subplot(1,2,2)
custom_plot2(ax2)
# 2. Plot in same line, on two rows
fig = plt.figure(figsize = (8,15)) # Changed the size of the figure, just aesthetic
ax1 = fig.add_subplot(2,1,1, projection = '3d') # Change the subplot arguments
custom_plot1(ax1)
ax2 = fig.add_subplot(2,1,2) # Change the subplot arguments
custom_plot2(ax2)
这不会显示两个不同的数字(这是我从“不同的线条”中理解的),而是将两个数字,一个在另一个之上,放在一个数字中.
现在,解释subplot参数:subplot(rows,cols,axnum)
行将是图形划分的行数.
cols将是该图被分成的列数.
axnum将是你要绘制的分区.
在你的情况下,如果你想并排两个图形,那么你想要一行有两列 – >副区(1,2,…)
在第二种情况下,如果你想要一个在另一个之上的两个图形,那么你想要2行和1列 – >副区(2,1,…)