1
我正在使用matplotlib。代碼:在循環中繪圖,只得到最後的陰謀
for new_counter in range(counter+1):
print new_counter
Qbers = final_data[(final_data["Dataset"]==counter) & (final_data["Qber"] > 0) ]
x1 = Qbers.index.tolist()
y1 = Qbers["Qber"].tolist()
Raws = final_data[(final_data["Dataset"]==counter) & (final_data["Raw key"] > 0) ]
x2 = Raws.index.tolist()
y2 = Raws["Raw key"].tolist()
# Two subplots, the axes array is 1-d http://matplotlib.org/examples/pylab_examples/subplots_demo.html
f, axarr = plt.subplots(2, sharex=True)
axarr[0].grid()
axarr[0].plot(x1, y1)
axarr[0].set_title('Sharing X axis')
axarr[1].grid()
axarr[1].plot(x2, y2)
plt.savefig(str(counter)+'foo.eps')
plt.clf()
我收到的文件只有最後一張圖,而我的數據我應該收到其中的6張。如何解決這個問題?附加問題:如何防止用plot創建交互式窗口?
這裏有一個相關的SO問題: http://stackoverflow.com/questions/1358977/how-to-make-several-plots-on-a-single-page-使用matplotlib – GomoX