-
-
Notifications
You must be signed in to change notification settings - Fork 8k
Closed
Labels
Release criticalFor bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions.For bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions.topic: animation
Milestone
Description
Bug report
Bug summary
I was trying to use FuncAnimation's save method to save an animation that I'd created to a .mp4 file, but it threw a TypeError when I ran my code (the animation displays fine with plt.show()).
Code for reproduction
import matplotlib.pyplot as plt
import matplotlib.animation as animation
import random
fig = plt.figure()
ax1 = fig.add_subplot(1, 1, 1)
x = [random.randint(0, 10) for _ in range(5)]
y = [random.randint(0, 10) for _ in range(5)]
def ani_func(i):
x.append(random.randint(0, 10))
y.append(random.randint(0, 10))
ax1.clear()
ax1.plot(x, y)
ani = animation.FuncAnimation(fig, ani_func, frames=10, repeat=False)
plt.show()
ani.save('test.mp4')
Actual outcome
The animation itself works fine in plt.show() producing this image as the last frame as expected:
However, the animation doesn't save to test.mp4
and instead throws a TypeError. I have included the entire traceback below.
Traceback (most recent call last):
File ".\disease_simulation\graphout.py", line 19, in <module>
ani.save('test.mp4')
File "C:\Users\menon\Desktop\disease-simulation\env\lib\site-packages\matplotlib\animation.py", line 1102, in save
alt_writer = next(writers, None)
TypeError: 'MovieWriterRegistry' object is not an iterator
Matplotlib version
- Operating system: Windows 10
- Matplotlib version: 3.2.1
- Matplotlib backend (
print(matplotlib.get_backend())
): TkAgg - Python version: 3.6.8
Matplotlib was installed via pip in a venv.
Metadata
Metadata
Assignees
Labels
Release criticalFor bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions.For bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions.topic: animation