Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Animation freezes in Jupyter notebook #18580

Closed
Milestone
@johnomotani

Description

@johnomotani

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp