Speed of animation with matplotlib.animation
ast
none at gmail.com
Tue Jun 19 04:34:55 EDT 2018
Hello
I noticed that the speed of animations made
with module matplotlib.animation always seems
wrong.
Here is a small example for demonstration purpose:
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.animation as animation
fig = plt.figure()
ax = fig.add_subplot(111)
txt = ax.text(0.5, 0.5, "", transform=ax.transAxes)
dt = 0.1 # 100 ms
def animate(i):
txt.set_text("time= %.1f" % (i*dt))
return txt,
ani = animation.FuncAnimation(fig=fig,
func=animate,
frames = 200,
interval = dt,
blit = True,
repeat=False)
plt.show()
----------------------
so function animate is ran every interval=dt=100ms
with i=0, 1, 2, ..., 200 and it simply prints time
(i*dt) on the figure.
The animation should last 20s, but on my computer
it is twice faster
A link to FuncAnimation doc: https://bit.ly/2t5UKjA
interval : number, optional
Delay between frames in milliseconds. Defaults to 200.
What's wrong ?
More information about the Python-list
mailing list