1

I want to generate a figure with 4 animations in python. I tried using the form below, but when running the program it generates the error ValueError: not enough values ​​to unpack (expected 4, got 2). What could be wrong?

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()
1

1 Answer 1

1

Note the parentheses:

fig, ((axF, axS), (axH, axHamilt)) = plt.subplots(2, 2)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.