Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

animation freezes in Jupyter notebook with matplotlib-3.3 #51

Closed
johnomotani opened this issue Sep 24, 2020 · 1 comment
Closed

animation freezes in Jupyter notebook with matplotlib-3.3 #51

johnomotani opened this issue Sep 24, 2020 · 1 comment

Comments

@johnomotani
Copy link
Contributor

In a simple Jupyter notebook based on the parametric example, playback freezes when using matplotlib-3.3.2, using the latest release animatplot-0.4.1.

Notebook contained (sorry, Github won't let me attach a .ipynb):

%matplotlib notebook
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.animation import PillowWriter
import animatplot as amp


def psi(t):
    x = t
    y = np.sin(t)
    return x, y


t = np.linspace(0, 2*np.pi, 25)
x, y = psi(t)

X, Y = amp.util.parametric_line(x, y)

timeline = amp.Timeline(t, 's', 24)

ax = plt.axes(xlim=[0, 7], ylim=[-1.1, 1.1])
block1 = amp.blocks.Line(X, Y, ax=ax)
# or equivalently
# block1 = amp.blocks.ParametricLine(x, y, ax=ax)

anim = amp.Animation([block1], timeline)

# Your standard matplotlib stuff
plt.title('Parametric Line')
plt.xlabel('x')
plt.ylabel(r'y')

# Create Interactive Elements
anim.toggle()
anim.timeline_slider()

and freezes with the error

[IPKernelApp] WARNING | Unknown error in handling startup files:
ERROR:tornado.application:Exception in callback <bound method TimerBase._on_timer of <matplotlib.backends.backend_webagg_core.TimerTornado object at 0x7fd353719b50>>
Traceback (most recent call last):
  File ".../python3.7/site-packages/tornado/ioloop.py", line 907, in _run
    return self.callback()
  File ".../python3.7/site-packages/matplotlib/backend_bases.py", line 1194, in _on_timer
    ret = func(*args, **kwargs)
  File ".../python3.7/site-packages/matplotlib/animation.py", line 1432, in _step
    self.event_source.interval = self._repeat_delay
  File ".../python3.7/site-packages/matplotlib/backend_bases.py", line 1135, in interval
    self._timer_set_interval()
  File ".../python3.7/site-packages/matplotlib/backends/backend_webagg_core.py", line 537, in _timer_set_interval
    self._timer_start()
  File ".../python3.7/site-packages/matplotlib/backends/backend_webagg_core.py", line 520, in _timer_start
    self.interval)
  File ".../python3.7/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

Animation worked as expected with matplotlib-3.2.2.

conda won't let me update just matplotlib from 3.2 to 3.3. Don't understand why, but it complained about package conflicts. So a few apparently unrelated packages had different versions in the environments I tested with. Output of conda env export below.
For matplotlib-3.2:

name: animatplot-test-matplotlib-3.2a
channels:
  - conda-forge
  - defaults
dependencies:
  - _libgcc_mutex=0.1=conda_forge
  - _openmp_mutex=4.5=1_gnu
  - animatplot=0.4.1=py_0
  - argon2-cffi=20.1.0=py37h8f50634_1
  - async_generator=1.10=py_0
  - attrs=20.2.0=pyh9f0ad1d_0
  - backports=1.0=py_2
  - backports.functools_lru_cache=1.6.1=py_0
  - bleach=3.2.1=pyh9f0ad1d_0
  - ca-certificates=2020.6.20=hecda079_0
  - certifi=2020.6.20=py37hc8dfbb8_0
  - cffi=1.14.3=py37h2b28604_0
  - cycler=0.10.0=py_2
  - dbus=1.13.6=he372182_0
  - decorator=4.4.2=py_0
  - defusedxml=0.6.0=py_0
  - entrypoints=0.3=py37hc8dfbb8_1001
  - expat=2.2.9=he1b5a44_2
  - fontconfig=2.13.1=h86ecdb6_1001
  - freetype=2.10.2=he06d7ca_0
  - gettext=0.19.8.1=hc5be6a0_1002
  - glib=2.66.0=h0dae87d_0
  - gst-plugins-base=1.14.5=h0935bb2_2
  - gstreamer=1.14.5=h36ae1b5_2
  - icu=64.2=he1b5a44_1
  - importlib-metadata=2.0.0=py37hc8dfbb8_0
  - importlib_metadata=2.0.0=0
  - ipykernel=5.3.4=py37h43977f1_0
  - ipython=5.8.0=py37_1
  - ipython_genutils=0.2.0=py_1
  - ipywidgets=7.5.1=pyh9f0ad1d_1
  - jinja2=2.11.2=pyh9f0ad1d_0
  - jpeg=9d=h516909a_0
  - jsonschema=3.2.0=py37hc8dfbb8_1
  - jupyter=1.0.0=py_2
  - jupyter_client=6.1.7=py_0
  - jupyter_console=5.2.0=py37_1
  - jupyter_core=4.6.3=py37hc8dfbb8_1
  - jupyterlab_pygments=0.1.1=pyh9f0ad1d_0
  - kiwisolver=1.2.0=py37h99015e2_0
  - ld_impl_linux-64=2.35=h769bd43_9
  - libblas=3.8.0=17_openblas
  - libcblas=3.8.0=17_openblas
  - libclang=9.0.1=default_hde54327_0
  - libffi=3.2.1=he1b5a44_1007
  - libgcc-ng=9.3.0=h24d8f2e_16
  - libgfortran-ng=7.5.0=hdf63c60_16
  - libgomp=9.3.0=h24d8f2e_16
  - libiconv=1.16=h516909a_0
  - liblapack=3.8.0=17_openblas
  - libllvm9=9.0.1=he513fc3_1
  - libopenblas=0.3.10=pthreads_hb3c22a3_4
  - libpng=1.6.37=hed695b0_2
  - libsodium=1.0.18=h516909a_0
  - libstdcxx-ng=9.3.0=hdf63c60_16
  - libuuid=2.32.1=h14c3975_1000
  - libxcb=1.13=h14c3975_1002
  - libxkbcommon=0.10.0=he1b5a44_0
  - libxml2=2.9.10=hee79883_0
  - markupsafe=1.1.1=py37h8f50634_1
  - matplotlib=3.2.2=1
  - matplotlib-base=3.2.2=py37h30547a4_0
  - mistune=0.8.4=py37h8f50634_1001
  - nbclient=0.5.0=py_0
  - nbconvert=6.0.6=py37hc8dfbb8_0
  - nbformat=5.0.7=py_0
  - ncurses=6.2=he1b5a44_1
  - nest-asyncio=1.4.0=py_1
  - notebook=6.1.4=py37hc8dfbb8_0
  - nspr=4.29=he1b5a44_0
  - nss=3.57=he751ad9_0
  - numpy=1.19.1=py37h7ea13bd_2
  - openssl=1.1.1h=h516909a_0
  - packaging=20.4=pyh9f0ad1d_0
  - pandoc=2.10.1=h516909a_0
  - pandocfilters=1.4.2=py_1
  - pcre=8.44=he1b5a44_0
  - pexpect=4.8.0=py37hc8dfbb8_1
  - pickleshare=0.7.5=py37hc8dfbb8_1001
  - pip=20.2.3=py_0
  - prometheus_client=0.8.0=pyh9f0ad1d_0
  - prompt_toolkit=1.0.15=py_1
  - pthread-stubs=0.4=h14c3975_1001
  - ptyprocess=0.6.0=py_1001
  - pycparser=2.20=pyh9f0ad1d_2
  - pygments=2.7.1=py_0
  - pyparsing=2.4.7=pyh9f0ad1d_0
  - pyqt=5.12.3=py37h8685d9f_3
  - pyrsistent=0.17.3=py37h8f50634_0
  - python=3.7.8=h6f2ec95_1_cpython
  - python-dateutil=2.8.1=py_0
  - python_abi=3.7=1_cp37m
  - pyzmq=19.0.2=py37hac76be4_0
  - qt=5.12.5=hd8c4c69_1
  - qtconsole=4.7.7=pyh9f0ad1d_0
  - qtpy=1.9.0=py_0
  - readline=8.0=he28a2e2_2
  - send2trash=1.5.0=py_0
  - setuptools=49.6.0=py37hc8dfbb8_1
  - simplegeneric=0.8.1=py_1
  - six=1.15.0=pyh9f0ad1d_0
  - sqlite=3.33.0=h4cf870e_0
  - terminado=0.9.1=py37hc8dfbb8_0
  - testpath=0.4.4=py_0
  - tk=8.6.10=hed695b0_0
  - tornado=6.0.4=py37h8f50634_1
  - traitlets=5.0.4=py_0
  - wcwidth=0.2.5=pyh9f0ad1d_1
  - webencodings=0.5.1=py_1
  - wheel=0.35.1=pyh9f0ad1d_0
  - widgetsnbextension=3.5.1=py37hc8dfbb8_1
  - xorg-libxau=1.0.9=h14c3975_0
  - xorg-libxdmcp=1.1.3=h516909a_0
  - xz=5.2.5=h516909a_1
  - zeromq=4.3.2=he1b5a44_3
  - zipp=3.2.0=py_0
  - zlib=1.2.11=h516909a_1009
  - pip:
    - pyqt5-sip==4.19.18
    - pyqtchart==5.12
    - pyqtwebengine==5.12.1
prefix: .../envs/animatplot-test-matplotlib-3.2a

and for matplotlib-3.3:

name: animatplot-test-matplotlib-3.3b
channels:
  - conda-forge
  - defaults
dependencies:
  - _libgcc_mutex=0.1=conda_forge
  - _openmp_mutex=4.5=1_gnu
  - animatplot=0.4.1=py_0
  - argon2-cffi=20.1.0=py37h8f50634_1
  - async_generator=1.10=py_0
  - attrs=20.2.0=pyh9f0ad1d_0
  - backports=1.0=py_2
  - backports.functools_lru_cache=1.6.1=py_0
  - bleach=3.2.1=pyh9f0ad1d_0
  - ca-certificates=2020.6.20=hecda079_0
  - certifi=2020.6.20=py37hc8dfbb8_0
  - cffi=1.14.3=py37h2b28604_0
  - cycler=0.10.0=py_2
  - dbus=1.13.6=he372182_0
  - decorator=4.4.2=py_0
  - defusedxml=0.6.0=py_0
  - entrypoints=0.3=py37hc8dfbb8_1001
  - expat=2.2.9=he1b5a44_2
  - fontconfig=2.13.1=h1056068_1002
  - freetype=2.10.2=he06d7ca_0
  - gettext=0.19.8.1=hc5be6a0_1002
  - glib=2.66.0=h0dae87d_0
  - gst-plugins-base=1.14.5=h0935bb2_2
  - gstreamer=1.14.5=h36ae1b5_2
  - icu=67.1=he1b5a44_0
  - importlib-metadata=2.0.0=py37hc8dfbb8_0
  - importlib_metadata=2.0.0=0
  - ipykernel=5.3.4=py37h43977f1_0
  - ipython=5.8.0=py37_1
  - ipython_genutils=0.2.0=py_1
  - ipywidgets=7.5.1=pyh9f0ad1d_1
  - jinja2=2.11.2=pyh9f0ad1d_0
  - jpeg=9d=h516909a_0
  - jsonschema=3.2.0=py37hc8dfbb8_1
  - jupyter=1.0.0=py_2
  - jupyter_client=6.1.7=py_0
  - jupyter_console=5.2.0=py37_1
  - jupyter_core=4.6.3=py37hc8dfbb8_1
  - jupyterlab_pygments=0.1.1=pyh9f0ad1d_0
  - kiwisolver=1.2.0=py37h99015e2_0
  - krb5=1.17.1=hfafb76e_3
  - lcms2=2.11=hbd6801e_0
  - ld_impl_linux-64=2.35=h769bd43_9
  - libblas=3.8.0=17_openblas
  - libcblas=3.8.0=17_openblas
  - libclang=10.0.1=default_hde54327_1
  - libedit=3.1.20191231=he28a2e2_2
  - libevent=2.1.10=hcdb4288_2
  - libffi=3.2.1=he1b5a44_1007
  - libgcc-ng=9.3.0=h24d8f2e_16
  - libgfortran-ng=7.5.0=hdf63c60_16
  - libgomp=9.3.0=h24d8f2e_16
  - libiconv=1.16=h516909a_0
  - liblapack=3.8.0=17_openblas
  - libllvm10=10.0.1=he513fc3_3
  - libopenblas=0.3.10=pthreads_hb3c22a3_4
  - libpng=1.6.37=hed695b0_2
  - libpq=12.3=h5513abc_0
  - libsodium=1.0.18=h516909a_0
  - libstdcxx-ng=9.3.0=hdf63c60_16
  - libtiff=4.1.0=hc7e4089_6
  - libuuid=2.32.1=h14c3975_1000
  - libwebp-base=1.1.0=h516909a_3
  - libxcb=1.13=h14c3975_1002
  - libxkbcommon=0.10.0=he1b5a44_0
  - libxml2=2.9.10=h68273f3_2
  - lz4-c=1.9.2=he1b5a44_3
  - markupsafe=1.1.1=py37h8f50634_1
  - matplotlib=3.3.2=0
  - matplotlib-base=3.3.2=py37hd478181_0
  - mistune=0.8.4=py37h8f50634_1001
  - mysql-common=8.0.21=2
  - mysql-libs=8.0.21=hf3661c5_2
  - nbclient=0.5.0=py_0
  - nbconvert=6.0.6=py37hc8dfbb8_0
  - nbformat=5.0.7=py_0
  - ncurses=6.2=he1b5a44_1
  - nest-asyncio=1.4.0=py_1
  - notebook=6.1.4=py37hc8dfbb8_0
  - nspr=4.29=he1b5a44_0
  - nss=3.57=he751ad9_0
  - numpy=1.19.1=py37h7ea13bd_2
  - olefile=0.46=py_0
  - openssl=1.1.1h=h516909a_0
  - packaging=20.4=pyh9f0ad1d_0
  - pandoc=2.10.1=h516909a_0
  - pandocfilters=1.4.2=py_1
  - pcre=8.44=he1b5a44_0
  - pexpect=4.8.0=py37hc8dfbb8_1
  - pickleshare=0.7.5=py37hc8dfbb8_1001
  - pillow=7.2.0=py37h718be6c_1
  - pip=20.2.3=py_0
  - prometheus_client=0.8.0=pyh9f0ad1d_0
  - prompt_toolkit=1.0.15=py_1
  - pthread-stubs=0.4=h14c3975_1001
  - ptyprocess=0.6.0=py_1001
  - pycparser=2.20=pyh9f0ad1d_2
  - pygments=2.7.1=py_0
  - pyparsing=2.4.7=pyh9f0ad1d_0
  - pyqt=5.12.3=py37h8685d9f_3
  - pyrsistent=0.17.3=py37h8f50634_0
  - python=3.7.8=h6f2ec95_1_cpython
  - python-dateutil=2.8.1=py_0
  - python_abi=3.7=1_cp37m
  - pyzmq=19.0.2=py37hac76be4_0
  - qt=5.12.9=h1f2b2cb_0
  - qtconsole=4.7.7=pyh9f0ad1d_0
  - qtpy=1.9.0=py_0
  - readline=8.0=he28a2e2_2
  - send2trash=1.5.0=py_0
  - setuptools=49.6.0=py37hc8dfbb8_1
  - simplegeneric=0.8.1=py_1
  - six=1.15.0=pyh9f0ad1d_0
  - sqlite=3.33.0=h4cf870e_0
  - terminado=0.9.1=py37hc8dfbb8_0
  - testpath=0.4.4=py_0
  - tk=8.6.10=hed695b0_0
  - tornado=6.0.4=py37h8f50634_1
  - traitlets=5.0.4=py_0
  - wcwidth=0.2.5=pyh9f0ad1d_1
  - webencodings=0.5.1=py_1
  - wheel=0.35.1=pyh9f0ad1d_0
  - widgetsnbextension=3.5.1=py37hc8dfbb8_1
  - xorg-libxau=1.0.9=h14c3975_0
  - xorg-libxdmcp=1.1.3=h516909a_0
  - xz=5.2.5=h516909a_1
  - zeromq=4.3.2=he1b5a44_3
  - zipp=3.2.0=py_0
  - zlib=1.2.11=h516909a_1009
  - zstd=1.4.5=h6597ccf_2
  - pip:
    - pyqt5-sip==4.19.18
    - pyqtchart==5.12
    - pyqtwebengine==5.12.1
prefix: .../envs/animatplot-test-matplotlib-3.3b
@johnomotani
Copy link
Contributor Author

This was a matplotlib issue matplotlib/matplotlib#18580, and was fixed in matplotlib-3.3.3.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant