Commit 0850ba0
committed
Cleanup Animation frame_formats.
- Warn if the requested frame format is unsupported and fallback occurs.
- ImageMagickFileWriter supports 'rgba' but requires explicit frame_size
and depth to do so (they are the same as for ImageMagickWriter, and
passing them doesn't negatively impact other formats); it does not
support 'raw' (per https://imagemagick.org/script/formats.php) but we
can just override it as 'rgba'.
Test script:
```python
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.animation as animation
fig, ax = plt.subplots()
x = np.arange(0, 2*np.pi, 0.01)
line, = ax.plot(x, np.sin(x))
def animate(i):
line.set_ydata(np.sin(x + i / 50)) # update the data.
return line,
ani = animation.FuncAnimation(
fig, animate, interval=50, blit=True, save_count=20)
plt.rcParams["animation.frame_format"] = "rgba" # or "raw"
writer = animation.FFMpegFileWriter() # or animation.ImageMagickFileWriter()
ani.save("/tmp/movie.mp4", writer=writer)
```
(Also move import of PIL up, as it's a standard dependency now.)1 parent 7c813db commit 0850ba0
1 file changed
Lines changed: 16 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
| 34 | + | |
34 | 35 | | |
35 | 36 | | |
36 | 37 | | |
| |||
263 | 264 | | |
264 | 265 | | |
265 | 266 | | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
266 | 271 | | |
267 | 272 | | |
268 | 273 | | |
| |||
296 | 301 | | |
297 | 302 | | |
298 | 303 | | |
299 | | - | |
300 | | - | |
| 304 | + | |
301 | 305 | | |
302 | 306 | | |
303 | 307 | | |
| |||
467 | 471 | | |
468 | 472 | | |
469 | 473 | | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
470 | 478 | | |
471 | 479 | | |
472 | 480 | | |
| |||
529 | 537 | | |
530 | 538 | | |
531 | 539 | | |
532 | | - | |
533 | 540 | | |
534 | 541 | | |
535 | 542 | | |
| |||
744 | 751 | | |
745 | 752 | | |
746 | 753 | | |
747 | | - | |
748 | 754 | | |
749 | 755 | | |
750 | 756 | | |
751 | 757 | | |
752 | 758 | | |
753 | 759 | | |
754 | | - | |
755 | | - | |
| 760 | + | |
| 761 | + | |
| 762 | + | |
| 763 | + | |
| 764 | + | |
| 765 | + | |
756 | 766 | | |
757 | 767 | | |
758 | 768 | | |
| |||
0 commit comments