我创建了一个具有两个子图的图形,并且在两个图形上都有一个三角形的数据,我无法解释。
我的代码是:
first, second, third, fourth, fifth, sixth, seventh, eighth = simulation(1000)
fig, (ax1, ax2) = plt.subplots(2, 1, sharex=True, sharey=True, figsize=(24, 24))
ax1.plot(first, second, third, fourth)
ax2.plot(fifth, sixth, seventh, eighth)
ax1.set_title('Hearer Index', fontsize=35)
ax1.xaxis.set_tick_params(labelsize=20)
ax1.yaxis.set_tick_params(labelsize=20)
ax1.plot(first, color='orange', alpha=0.3, label='First')
ax1.plot(second, color='blue', alpha=0.3, label='Second')
ax1.plot(third, color='red', alpha=0.3, label='Third')
ax1.plot(fourth, color='green', alpha=0.3, label='Fourth')
ax1.set_ylabel('Frequency', fontsize=35)
ax1.grid()
ax2.set_title('Speaker Index', fontsize=35)
ax2.xaxis.set_tick_params(labelsize=20)
ax2.yaxis.set_tick_params(labelsize=20)
ax2.plot(fifth, color='orange', alpha=0.3, label='First')
ax2.plot(sixth, color='blue', alpha=0.3, label='Second')
ax2.plot(seventh, color='red', alpha=0.3, label='Third')
ax2.plot(eighth, color='green', alpha=0.3, label='Fourth')
ax2.set_xlabel('Generations', fontsize=35)
ax2.set_ylabel('Frequency', fontsize=35)
ax2.grid()
fig.savefig('Question2.pdf')
fig.subplots_adjust(hspace=0.25)
我希望能够创建相同的图形,但是在每个子图的左侧都没有主要的橙色/蓝色数据
编辑:当ax1.plot(first, color='orange', alpha=0.3, label='First')
和ax2.plot(fifth, color='orange', alpha=0.3, label='First')
答案 0 :(得分:0)
我犯的错误是在做
ax1.plot(first, second, third, fourth)
ax2.plot(fifth, sixth, seventh, eighth)
这是不必要的,因为我稍后在代码中再次绘制它们。