0
def simulate(foo):
  plt.cla()
  for key in plotdata.keys():
        plt.plot(plotdata[key],label = key[:-1],color = key[-1])
  #do some stuff with data
ani = ani.FuncAnimation(plt.gcf(), simulate, interval = secsbetweengenerations * 100)
plt.legend()
plt.show()

The data is never empty, and the contents of them are always floats between 0 and 1. It shows an empty graph tho

I tried to remove

plt.cla() 

and add

plt.axis([0,plotrange-1,0,1]) 

before the animation

3
  • Did you look at the error produced? When I ran your (non-self contained) code I got TypeError: simulate() takes 0 positional arguments but 1 was given because your simulate() function needs to take a frame number argument. See matplotlib.org/stable/api/animation_api.html Commented Feb 3, 2023 at 23:15
  • @JodyKlymak I did I only forgot to put it here. There is no exception Commented Feb 4, 2023 at 6:23
  • The reason we ask for complete, minimal., self-contained examples is so that we can tell what is wrong. Suggest you concoct such an example, and if that doesn't reveal the cause of your problem, please repost Commented Feb 4, 2023 at 22:34

0

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.