-
Notifications
You must be signed in to change notification settings - Fork 38
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
[Bug] .gif files don't loop #24
Comments
This is actually a bug with matplotlib's pillowWriter. See matplotlib/matplotlib#11787. I submitted a bug fix and it will be released with matplotlib 3.1. I actually monkey patched the fix into my local version of matplotlib, so that when I made the documentation the gif's looped. You can use |
Changing to imagemagick with that command worked, thanks! |
As a workaround using Pillow, you can subclass PillowWriter: from matplotlib.animation import PillowWriter
class LoopingPillowWriter(PillowWriter):
def finish(self):
self._frames[0].save(
self._outfile, save_all=True, append_images=self._frames[1:],
duration=int(1000 / self.fps), loop=0)
ani = ArtistAnimation(fig, images)
ani.save('data.gif', writer=LoopingPillowWriter(fps=15)) |
Just to note that I am having this error too and look forward to a fix from the matplotlib folks. Loving this software though! Cheers |
... Just a quick note to say that a quick workaround is to save the gif and then run this at the terminal...
Works for me! |
.gif files created with
animatplot
only run once through, then stop on the final frame. They do loop properly when running interactively (in a Jupyter notebook) though.I'm creating a gif in a jupyter notebook, using
%matplotlib notebook
. I save the gif, then try to open it usingThis displays the gif once through, then it stops on the final frame. If I rerun the cell then it just opens a static image of the final frame.
If I open the .gif file with another program it also stops on the final frame, so I think it's a problem with the created file.
I've tried explicitly passing
repeat=True
toFuncAnimation()
insideanimatplot.Animation
, and I've also tried using theimagemagick
writer rather thanPillowWriter
, but the problem persists.A reproducible example, which is basically just this example):
Also the output of using
conda list
to see which versions of everything I'm using:The text was updated successfully, but these errors were encountered: