@@ -68,7 +68,7 @@ def adjusted_figsize(w, h, dpi, n):
68
68
69
69
# A registry for available MovieWriter classes
70
70
class MovieWriterRegistry (object ):
71
- '''Registry of of available writer classes by human readable name
71
+ '''Registry of available writer classes by human readable name
72
72
'''
73
73
def __init__ (self ):
74
74
self .avail = dict ()
@@ -111,13 +111,14 @@ def list(self):
111
111
return list (self .avail .keys ())
112
112
113
113
def is_available (self , name ):
114
- '''If given writer is available
114
+ '''Check if given writer is available by name
115
115
116
116
Parameters
117
117
----------
118
118
name : str
119
119
120
120
Returns
121
+ -------
121
122
available : bool
122
123
'''
123
124
self .ensure_not_dirty ()
@@ -141,42 +142,19 @@ class MovieWriter(object):
141
142
Attributes
142
143
----------
143
144
144
- frame_format : string
145
+ frame_format : str
145
146
The format used in writing frame data, defaults to 'rgba'
146
147
147
148
fig : `~matplotlib.figure.Figure`
148
149
The figure to capture data from.
149
- This must be provided by the sub-classes
150
-
151
- Examples
152
- --------
153
-
154
- Fundamentally, what a MovieWriter does is provide is a way to grab
155
- frames by calling grab_frame(). setup() is called to start the
156
- process and finish() is called afterwards ::
157
-
158
- moviewriter = MovieWriter(...)
159
- moveiewriter.setup()
160
- for j in range(n):
161
- update_figure(n)
162
- moviewriter.grab_frame()
163
- moviewriter.finish()
164
-
165
-
166
- saving() is provided as a context manager to facilitate this process as::
167
-
168
- with moviewriter.saving('myfile.mp4'):
169
- # Iterate over frames
170
- moviewriter.grab_frame()
171
-
172
- The use of the context manager ensures that setup and cleanup are
173
- performed as necessary.
150
+ This must be provided by the sub-classes.
174
151
175
152
'''
176
153
177
154
def __init__ (self , fps = 5 , codec = None , bitrate = None , extra_args = None ,
178
155
metadata = None ):
179
- '''
156
+ '''MovieWriter
157
+
180
158
Parameters
181
159
----------
182
160
fps: int
@@ -371,31 +349,28 @@ class FileMovieWriter(MovieWriter):
371
349
This must be sub-classed to be useful.
372
350
'''
373
351
def __init__ (self , * args , ** kwargs ):
374
- '''
375
- Parameters
376
- ----------
377
- fig : `matplotlib.Figure` instance
378
- The figure object that contains the information for frames
379
- outfile : string
380
- The filename of the resulting movie file
381
- dpi : int
382
- The DPI (or resolution) for the file. This controls the size
383
- in pixels of the resulting movie file.
384
- frame_prefix : string, optional
385
- The filename prefix to use for the temporary files. Defaults
386
- to '_tmp'
387
- clear_temp : bool
388
- Specifies whether the temporary files should be deleted after
389
- the movie is written. (Useful for debugging.) Defaults to True.
390
-
391
- '''
392
-
393
352
MovieWriter .__init__ (self , * args , ** kwargs )
394
353
self .frame_format = rcParams ['animation.frame_format' ]
395
354
396
355
def setup (self , fig , outfile , dpi , frame_prefix = '_tmp' , clear_temp = True ):
397
- '''
398
- Perform setup for writing the movie file.
356
+ '''Perform setup for writing the movie file.
357
+
358
+ Parameters
359
+ ----------
360
+ fig : matplotlib.figure.Figure
361
+ The figure to grab the rendered frames from.
362
+ outfile : str
363
+ The filename of the resulting movie file.
364
+ dpi : number
365
+ The dpi of the output file. This, with the figure size,
366
+ controls the size in pixels of the resulting movie file.
367
+ frame_prefix : str, optional
368
+ The filename prefix to use for temporary files. Defaults to
369
+ '_tmp'.
370
+ clear_temp : bool, optional
371
+ If the temporary files should be deleted after stitching
372
+ the final result. Setting this to `False` can be useful for
373
+ debugging. Defaults to `True`.
399
374
400
375
'''
401
376
self .fig = fig
@@ -541,7 +516,7 @@ def output_args(self):
541
516
# Combine FFMpeg options with pipe-based writing
542
517
@writers .register ('ffmpeg' )
543
518
class FFMpegWriter (MovieWriter , FFMpegBase ):
544
- '''Pipe based ffmpeg writer.
519
+ '''Pipe- based ffmpeg writer.
545
520
546
521
Frames are streamed directly to ffmpeg via a pipe and written in a single
547
522
pass.
@@ -562,7 +537,7 @@ def _args(self):
562
537
# Combine FFMpeg options with temp file-based writing
563
538
@writers .register ('ffmpeg_file' )
564
539
class FFMpegFileWriter (FileMovieWriter , FFMpegBase ):
565
- '''File based ffmpeg writer
540
+ '''File- based ffmpeg writer
566
541
567
542
Frames are written to temporary files on disk and then stitched
568
543
together at the end.
@@ -595,7 +570,7 @@ class AVConvBase(FFMpegBase):
595
570
# Combine AVConv options with pipe-based writing
596
571
@writers .register ('avconv' )
597
572
class AVConvWriter (AVConvBase , FFMpegWriter ):
598
- '''Pipe based avconv writer.
573
+ '''Pipe- based avconv writer.
599
574
600
575
Frames are streamed directly to avconv via a pipe and written in a single
601
576
pass.
@@ -605,7 +580,7 @@ class AVConvWriter(AVConvBase, FFMpegWriter):
605
580
# Combine AVConv options with file-based writing
606
581
@writers .register ('avconv_file' )
607
582
class AVConvFileWriter (AVConvBase , FFMpegFileWriter ):
608
- '''File based avconv writer
583
+ '''File- based avconv writer
609
584
610
585
Frames are written to temporary files on disk and then stitched
611
586
together at the end.
@@ -750,7 +725,7 @@ def isAvailable(cls):
750
725
# former.
751
726
@writers .register ('imagemagick' )
752
727
class ImageMagickWriter (ImageMagickBase , MovieWriter ):
753
- '''Pipe based animated gif
728
+ '''Pipe- based animated gif
754
729
755
730
Frames are streamed directly to ImageMagick via a pipe and written
756
731
in a single pass.
@@ -770,7 +745,7 @@ def _args(self):
770
745
# former.
771
746
@writers .register ('imagemagick_file' )
772
747
class ImageMagickFileWriter (ImageMagickBase , FileMovieWriter ):
773
- '''File based animated gif writer
748
+ '''File- based animated gif writer
774
749
775
750
Frames are written to temporary files on disk and then stitched
776
751
together at the end.
@@ -895,7 +870,7 @@ class to use, such as 'ffmpeg' or 'mencoder'. If `None`,
895
870
codec : str, optional
896
871
the video codec to be used. Not all codecs are supported by
897
872
a given :class:`MovieWriter`. If `None`,
898
- default to ``rcParams['animation.codec']``
873
+ default to ``rcParams['animation.codec']``
899
874
900
875
bitrate : number, optional
901
876
specifies the amount of bits used per second in the
@@ -931,7 +906,7 @@ class to use, such as 'ffmpeg' or 'mencoder'. If `None`,
931
906
-----
932
907
fps, codec, bitrate, extra_args, metadata are used are used to
933
908
construct a :class:`MovieWriter` instance and can only be
934
- passed if `writer` is a string. If they are pass as
909
+ passed if `writer` is a string. If they are passed as
935
910
non-`None` and ``writer`` is a :class:`MovieWriter`, a
936
911
`RuntimeError` will be raised.
937
912
@@ -1220,15 +1195,15 @@ class TimedAnimation(Animation):
1220
1195
other needed events.
1221
1196
1222
1197
interval : number, optional
1223
- Delay between frames. Defaults to 200
1198
+ Delay between frames in milliseconds . Defaults to 200.
1224
1199
1225
1200
repeat_delay : number, optional
1226
1201
If the animation in repeated, adds a delay in milliseconds
1227
1202
before repeating the animation. Defaults to None
1228
1203
1229
1204
repeat: bool, optional
1230
1205
controls whether the animation should repeat when the sequence
1231
- of frames is completed.
1206
+ of frames is completed. Defaults to `True`.
1232
1207
1233
1208
blit : bool, optional
1234
1209
controls whether blitting is used to optimize drawing. Defaults
@@ -1309,15 +1284,15 @@ class ArtistAnimation(TimedAnimation):
1309
1284
be disabled for other frames.
1310
1285
1311
1286
interval : number, optional
1312
- Delay between frames. Defaults to 200
1287
+ Delay between frames in miliseconds . Defaults to 200.
1313
1288
1314
1289
repeat_delay : number, optional
1315
1290
If the animation in repeated, adds a delay in milliseconds
1316
- before repeating the animation. Defaults to None
1291
+ before repeating the animation. Defaults to ` None`.
1317
1292
1318
1293
repeat: bool, optional
1319
1294
controls whether the animation should repeat when the sequence
1320
- of frames is completed.
1295
+ of frames is completed. Defaults to `True`.
1321
1296
1322
1297
blit : bool, optional
1323
1298
controls whether blitting is used to optimize drawing. Defaults
@@ -1381,7 +1356,6 @@ class FuncAnimation(TimedAnimation):
1381
1356
other needed events.
1382
1357
1383
1358
func : callable
1384
-
1385
1359
The function to call at each frame. The first argument will
1386
1360
be the next value in ``frames``. Any additional positional
1387
1361
arguments can be supplied via the ``fargs`` parameter.
@@ -1390,7 +1364,6 @@ class FuncAnimation(TimedAnimation):
1390
1364
1391
1365
def func(fr: object, *fargs) -> iterable_of_artists:
1392
1366
1393
-
1394
1367
frames : iterable, int, generator function, or None, optional
1395
1368
Source of data to pass ``func`` and each frame of the animation
1396
1369
@@ -1406,7 +1379,6 @@ def gen_function():
1406
1379
If `None`, then equivalent to passing ``itertools.count``
1407
1380
1408
1381
init_func : callable, optional
1409
-
1410
1382
a function used to draw a clear frame. If not given, the
1411
1383
results of drawing from the first item in the frames sequence
1412
1384
will be used. This function will be called once before the
@@ -1426,15 +1398,15 @@ def init_func() -> iterable_of_artists:
1426
1398
The number of values from `frames` to cache.
1427
1399
1428
1400
interval : number, optional
1429
- Delay between frames. Defaults to 200
1401
+ Delay between frames in milliseconds . Defaults to 200.
1430
1402
1431
1403
repeat_delay : number, optional
1432
1404
If the animation in repeated, adds a delay in milliseconds
1433
- before repeating the animation. Defaults to None
1405
+ before repeating the animation. Defaults to ` None`.
1434
1406
1435
1407
repeat: bool, optional
1436
1408
controls whether the animation should repeat when the sequence
1437
- of frames is completed.
1409
+ of frames is completed. Defaults to `True`
1438
1410
1439
1411
blit : bool, optional
1440
1412
controls whether blitting is used to optimize drawing. Defaults
0 commit comments