Update README.md

Signed-off-by: David Rotermund <54365609+davrot@users.noreply.github.com>
This commit is contained in:
David Rotermund 2023-12-21 15:55:48 +01:00 committed by GitHub
parent 52fa281152
commit 447368cbd0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -150,6 +150,25 @@ animation = matplotlib.animation.FuncAnimation(
plt.show() plt.show()
``` ```
## Save the animation
```python
save(filename[, writer, fps, dpi, codec, ...])
```
> Save the animation as a movie file by drawing every frame.
You need to add the save-method between **animation = matplotlib.animation.FuncAnimation(...)** and **plt.show()**.
```python
movie_filename: str | None = "movie.mp4"
if movie_filename is not None:
animation.save(movie_filename)
```
Please note that you may need the [ffmpeg binaries](https://www.ffmpeg.org/download.html) for MP4. The ffmpeg files need to be accessable by Python. i.e. Python needs to know where they are. Under Windows it is helpful to place the three exe files in the binary directory of Python. Under Linux, the distribution package manager should take care of it.
## Interactive Python session ## Interactive Python session
There are several options if you don't run it from VS Code interactively. One options is this: There are several options if you don't run it from VS Code interactively. One options is this:
@ -159,4 +178,13 @@ There are several options if you don't run it from VS Code interactively. One op
%matplotlib widget %matplotlib widget
``` ```
Another one is this:
```python
# %%
%matplotlib tk
```
Please check yourself which suits your setup best.