Thanks to visit codestin.com Credit goes to github.com
We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 1644a4e commit 33e4bb0Copy full SHA for 33e4bb0
1 file changed
examples/animation/moviewriter.py
@@ -0,0 +1,27 @@
1
+# This example uses a MovieWriter directly to grab individual frames and
2
+# write them to a file. This avoids any event loop integration, but has
3
+# the advantage of working with even the Agg backend. This is not recommended
4
+# for use in an interactive setting.
5
+
6
+import numpy as np
7
+import matplotlib.pyplot as plt
8
+import matplotlib.animation as manimation
9
10
+FFMpegWriter = manimation.writers['ffmpeg']
11
+writer = FFMpegWriter(fps=15)
12
13
+fig = plt.figure()
14
+l, = plt.plot([], [], 'k-o')
15
16
+plt.xlim(-5, 5)
17
+plt.ylim(-5, 5)
18
19
+x0,y0 = 0, 0
20
21
+with writer.saving(fig, "writer_test.mp4", 100):
22
+ for i in range(100):
23
+ x0 += 0.1 * np.random.randn()
24
+ y0 += 0.1 * np.random.randn()
25
+ l.set_data(x0, y0)
26
+ writer.grab_frame()
27
0 commit comments