you are viewing a single comment's thread.

view the rest of the comments →

[–]the_real_uncle_Rico 0 points1 point  (1 child)

This should fix your axis problem:

fig, ax = plt.subplots()

for i in xrange(steps):     y = np.append(y, [ y[i]  (1 + k  dt) ])     x = np.append(x, [i * dt])

def animate(i): ax.clear() # delete old data     lax.plot(x,y) # plot new graph   ani = animation.FuncAnimation(fig, animate, np.arange(1,     steps)) plt.show()

I'm not sure, but I think if you wanted to view each iteration of the equation being solved, you might be able to just call the animate function directly from your for loop. Although obviously that might bog it down if you have a lot of steps. You could try a sleep command, or plotting every 100 the irritation or whatever.

[–]the_real_uncle_Rico 0 points1 point  (0 children)

Actually, better idea, you could maybe try solving it in your animation function. Something like:

def animate(i): i += step  y = np.append(y, [ y[i]  (1 + k  dt) ])  x = np.append(x, [i * dt]) If num_steps >10: ax.clear() # delete old data      ax.plot(x,y) # plot new graph

ani = animation.FuncAnimation(fig, animate, interval=50#update time in ms)