pillow is the only animation writer that does not require additional dependencies (we already depend on pillow in any case) but it is not the default writer. I think the main animation formation it can save to is gif.
There should be a simple "save as gif with pillow example" with its own entry in https://matplotlib.org/devdocs/gallery/index#animation (although some of the examples have a few lines on saving as mp4 with ffmpeg, 1. it is not even clear from the index which are these examples, and 2. ffmpeg may or may not be present on the user's machine).
What we really need is an animation tutorial/explanation. This should explain the logic of animations and could then also have a section on saving to file. The individual examples should link to the tutorial for further information.
Labeling good first issue because this is relatively simple and stand alone. Also agree we need a user level "how to animate" tutorial, but I think this example can be generated independent of that.
Are we thinking something simple like this? (it moves faster and smoother when run from the terminal)
Also what would be the best way we want to write the save to gif as?
# To save the animation, use e.g.## ani.save("movie.mp4")## or## writer = animation.FFMpegWriter(# fps=15, metadata=dict(artist='Me'), bitrate=1800)# ani.save("movie.mp4", writer=writer)
# To save the animation using Pillow as a gif, use e.g.## writer = animation.PillowWriter(fps=15,# metadata=dict(artist='Me'),# bitrate=1800)# ani.save('scatter.gif', writer=writer)
@story645 just had a thought if it's not in comments when the docs are built will the code generate an image if it has ani.save('scatter.gif', writer=writer) uncommented?
Activity
timhoffm commented on Feb 2, 2022
What we really need is an animation tutorial/explanation. This should explain the logic of animations and could then also have a section on saving to file. The individual examples should link to the tutorial for further information.
story645 commented on Jul 14, 2022
Labeling good first issue because this is relatively simple and stand alone. Also agree we need a user level "how to animate" tutorial, but I think this example can be generated independent of that.
kostyafarber commented on Sep 23, 2022
This sounds interesting. Any suggestions on what animation we would want to use for this example?
story645 commented on Sep 25, 2022
I think something small like moving a scatter dot across the page - it's not documented as its own thing like line is (https://matplotlib.org/devdocs/gallery/animation/simple_anim.html#sphx-glr-gallery-animation-simple-anim-py) but is fairly small so won't distract from the save as gif? (plus it works really well as an infinite gif)
ETA: https://matplotlib.org/devdocs/gallery/animation/rain.html#sphx-glr-gallery-animation-rain-py has how to animate scatter, it's just the complex version
kostyafarber commented on Oct 2, 2022
No worries I'll have a look at it and try mock something up.
kostyafarber commented on Oct 2, 2022
Hey,
Are we thinking something simple like this? (it moves faster and smoother when run from the terminal)
Also what would be the best way we want to write the save to gif as?
Something like the above?
Cheers,
Kostya
kostyafarber commented on Oct 4, 2022
@story645
story645 commented on Oct 4, 2022
that works for me, except the save has to be explicitly using pillow as the writer and the two examples you have are the built in mp4 and ffmpeg.
https://matplotlib.org/stable/api/_as_gen/matplotlib.animation.PillowWriter.html?highlight=pillow#matplotlib.animation.PillowWriter
kostyafarber commented on Oct 4, 2022
No worries I'll have a look into it and post the code block here. Thanks.
kostyafarber commented on Oct 4, 2022
How does this look?
story645 commented on Oct 4, 2022
I'm not sure if it needs to be in comments
kostyafarber commented on Oct 4, 2022
Sure thing I can uncomment in the code.
kostyafarber commented on Oct 4, 2022
@story645 just had a thought if it's not in comments when the docs are built will the code generate an image if it has ani.save('scatter.gif', writer=writer) uncommented?
Might be better to comment out then?
melissawm commented on May 26, 2023
Now that the animation tutorial has been merged, do we still need to keep this issue open?
timhoffm commented on May 26, 2023
This is now covered in https://matplotlib.org/devdocs/users/explain/animations/animations.html#saving-animations