0
我想在matplotplib
中繪製,顯示並保存多個圖。所以,我用當在多個窗口中繪製多個圖時,Matplotlib AttributeError
import matplotlib.pyplot as plt
x1, y1 = [0,1,2,3], [1,2,3,4]
x2, y2 = [0,1,2,3], [1,2,3,4]
x3, y3 = [0,1,2,3], [1,2,3,4]
x4, y4 = [0,1,2,3], [1,2,3,4]
x5, y5 = [0,1,2,3], [1,2,3,4]
x6, y6 = [0,1,2,3], [1,2,3,4]
ax=plt.figure(1)
bx=plt.figure(2)
cx=plt.figure(3)
dx=plt.figure(4)
ex=plt.figure(5)
fx=plt.figure(6)
gx=plt.figure(7)
ax.axes.errorbar(x,y,yerr=std)
bx.axes.errorbar(x1,y1,yerr=std1)
cx.axes.errorbar(x2,y2,yerr=std2)
dx.axes.errorbar(x3,y3,yerr=std3)
ex.axes.errorbar(x4,y4,yerr=std4)
fx.axes.errorbar(x5,y5,yerr=std5)
gx.axes.errorbar(x6,y6,yerr=std6)
ax.figure.show(1)
bx.figure.show(2)
cx.figure.show(3)
dx.figure.show(4)
ex.figure.show(5)
fx.figure.show(6)
gx.figure.show(7)
,我得到了錯誤AttributeError: 'list' object has no attribute 'errorbar'
,當我使用ax.errobar
,而不是ax.axes.errorbar
我得到的錯誤AttributeError: 'Figure' object has no attribute 'errorbar'
。所以,我想知道我的代碼有什麼問題。
感謝
謝謝。我閱讀了「圖」的文檔,但我沒有得到如何用'fig.add_axes(ax)'工作。 – motaha
您是否嘗試添加'[0]'將'Axes'實例拉出'axes'列表? –
是的,我做了,我得到了索引錯誤,所以我參考了'圖'文檔,並不知道如何添加軸將有助於或如何做到這一點 – motaha