Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork7.9k
Closed
Labels
Milestone
Description
Bug report
Bug summary
AFuncAnimation
in a Jupyter notebook runs through once but freezes when it should repeat.
Code for reproduction
%matplotlibnotebookimportmatplotlibasmplfrommatplotlibimportpyplotaspltimportnumpyasnpfig=plt.figure()nt=25t=np.linspace(0,1,nt)f=np.sin(2.*np.pi*t)ax=plt.axes(xlim=[0,1],ylim=[-1,1])line=ax.plot(t[:1],f[:1])[0]defupdate_func(i):line.set_xdata(t[:i])line.set_ydata(f[:i])anim=mpl.animation.FuncAnimation(fig,update_func,nt,repeat=True)
Passingrepeat_delay=1
toFuncAnimation
on the last line prevents the error. It looks like havingrepeat_delay=0
setsTimerTornado.interval
to0
, buttornado.ioloop.PeriodicCallback
requires apositive value forinterval
.
Actual outcome
This error appears in the console when the animation crashes.
ERROR:tornado.application:Exception in callback <bound method TimerBase._on_timer of <matplotlib.backends.backend_webagg_core.TimerTornado object at 0x7f8627585610>>Traceback (most recent call last): File ".../site-packages/tornado/ioloop.py", line 907, in _run return self.callback() File ".../site-packages/matplotlib/backend_bases.py", line 1194, in _on_timer ret = func(*args, **kwargs) File ".../site-packages/matplotlib/animation.py", line 1432, in _step self.event_source.interval = self._repeat_delay File ".../site-packages/matplotlib/backend_bases.py", line 1135, in interval self._timer_set_interval() File ".../site-packages/matplotlib/backends/backend_webagg_core.py", line 537, in _timer_set_interval self._timer_start() File ".../site-packages/matplotlib/backends/backend_webagg_core.py", line 518, in _timer_start self._timer = tornado.ioloop.PeriodicCallback( File ".../site-packages/tornado/ioloop.py", line 873, in __init__ raise ValueError("Periodic callback must have a positive callback_time")ValueError: Periodic callback must have a positive callback_time
Expected outcome
The animation plays continuously.
Matplotlib version
- Operating system: Linux Mint 19
- Matplotlib version: 3.3.2
- Matplotlib backend (
print(matplotlib.get_backend())
): nbAgg - Python version: 3.8.5
- Jupyter version (if applicable): 6.1.4
- Other libraries:
- IPython: 7.18.1
- tornado: 6.0.4
Installed all packages from conda, using conda-forge