我想在 python 中生成一個帶有 4 個影片的圖形。我嘗試使用下面的表格,但是在運行程式時會生成錯誤ValueError: not enough values ??to unpack (expected 4, got 2)。有什么問題?
fig, (axF, axS, axH, axHamilt) = plt.subplots(2, 2)
graphF,=axF.plot([],[])
graphS,=axS.plot([],[])
graphH,=axH.plot([],[])
graphHamilt,=axHamilt.plot([],[])
axF.set_ylim(-1.5, 1.5)
axF.set_xlim(ri, rf)
axF.grid()
axS.set_ylim(-1.5, 1.5)
axS.set_xlim(ri, rf)
axS.grid()
axH.set_ylim(-1.5, 1.5)
axH.set_xlim(ri, rf)
axH.grid()
axHamilt.set_ylim(-1.5, 1.5)
axHamilt.set_xlim(ri, rf)
axHamilt.grid()
def animate(i):
graphF.set_data(r,Sevol[i])
graphS.set_data(r, Fevol[i])
graphH.set_data(r, Hevol[i])
graphHamilt.set_data(r, Hevol[i])
return graphF, graphS, graphH, graphHamilt
ani = FuncAnimation(fig, animate, frames=N_plots, interval=100)
plt.show()
uj5u.com熱心網友回復:
注意括號:
fig, ((axF, axS), (axH, axHamilt)) = plt.subplots(2, 2)
轉載請註明出處,本文鏈接:https://www.uj5u.com/qukuanlian/512067.html
