Problem with animations in matplotlib >= 3.3
txominpelu opened this issue · comments
First of all thanks for this awesome library. I really like being able to plot matplot graphs in iterm.
It's also great to be able to draw animations although I am experiencing some issues when trying to do so.
This is my current Pipfile
[[source]]
name = "pypi"
url = "https://pypi.org/simple"
verify_ssl = true
[dev-packages]
[packages]
pip = "*"
install = "*"
itermplot = "==0.5"
networkx = "*"
matplotlib = "==3.3.1"
[requires]
python_version = "3.7"
With this dependencies I am trying to run this animation example but the animation doesn't seem to happen. I've only managed to create an animation effect with this code:
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.animation as animation
import time
from datetime import datetime
fig, ax = plt.subplots()
x = np.arange(0, 2*np.pi, 0.01)
line, = ax.plot(x, np.sin(x))
def animate(axes):
axes.set_title(datetime.now())
axes.figure.canvas.draw()
timer = fig.canvas.new_timer(interval=1000)
fig.canvas.timer = timer
timer.add_callback(animate, ax)
timer.start()
plt.show()
However to be able to run this code I had to set manually the matplotlib version to 3.3.1
(I just picked anything else than 3.4.2) because running the same code with the more recent version of matplotlib failed with the following error:
Traceback (most recent call last):
File "animate.py", line 21, in <module>
plt.show()
File "/Users/inigo.mediavilla/.local/share/virtualenvs/learn-draw-zC7riZv8/lib/python3.7/site-packages/matplotlib/pyplot.py", line 378, in show
return _backend_mod.show(*args, **kwargs)
File "/Users/inigo.mediavilla/.local/share/virtualenvs/learn-draw-zC7riZv8/lib/python3.7/site-packages/itermplot/__init__.py", line 140, in show
figmanager.show()
File "/Users/inigo.mediavilla/.local/share/virtualenvs/learn-draw-zC7riZv8/lib/python3.7/site-packages/itermplot/__init__.py", line 295, in show
data = self.animate(loops, outfile)
File "/Users/inigo.mediavilla/.local/share/virtualenvs/learn-draw-zC7riZv8/lib/python3.7/site-packages/itermplot/__init__.py", line 269, in animate
writer.grab_frame()
File "/Users/inigo.mediavilla/.pyenv/versions/3.7.7/lib/python3.7/contextlib.py", line 119, in __exit__
next(self.gen)
File "/Users/inigo.mediavilla/.local/share/virtualenvs/learn-draw-zC7riZv8/lib/python3.7/site-packages/matplotlib/animation.py", line 238, in saving
self.finish()
File "/Users/inigo.mediavilla/.local/share/virtualenvs/learn-draw-zC7riZv8/lib/python3.7/site-packages/matplotlib/animation.py", line 345, in finish
overridden_cleanup()
File "/Users/inigo.mediavilla/.local/share/virtualenvs/learn-draw-zC7riZv8/lib/python3.7/site-packages/itermplot/__init__.py", line 252, in cleanup
self._frame_sink().close()
AttributeError: 'ItermplotImageMagickWriter' object has no attribute '_frame_sink'
Are you aware of limitations with the more recent versions of matplotlib ?
Note: I'd be happy to come up with PRs to document the supported versions and maybe even fixes to that itermplot keeps working for them.