@@ -1014,7 +1014,8 @@ def _stop(self, *args):
1014
1014
def save (self , filename , writer = None , fps = None , dpi = None , codec = None ,
1015
1015
bitrate = None , extra_args = None , metadata = None , extra_anim = None ,
1016
1016
savefig_kwargs = None ):
1017
- '''Saves a movie file by drawing every frame.
1017
+ """
1018
+ Save the animation as a movie file by drawing every frame.
1018
1019
1019
1020
Parameters
1020
1021
----------
@@ -1025,7 +1026,7 @@ def save(self, filename, writer=None, fps=None, dpi=None, codec=None,
1025
1026
writer : :class:`MovieWriter` or str, optional
1026
1027
A `MovieWriter` instance to use or a key that identifies a
1027
1028
class to use, such as 'ffmpeg'. If ``None``, defaults to
1028
- :rc:`animation.writer`.
1029
+ :rc:`animation.writer` = 'ffmpeg' .
1029
1030
1030
1031
fps : number, optional
1031
1032
Frames per second in the movie. Defaults to ``None``, which will use
@@ -1039,13 +1040,13 @@ class to use, such as 'ffmpeg'. If ``None``, defaults to
1039
1040
codec : str, optional
1040
1041
The video codec to be used. Not all codecs are supported
1041
1042
by a given :class:`MovieWriter`. If ``None``, default to
1042
- :rc:`animation.codec`.
1043
+ :rc:`animation.codec` = 'h264' .
1043
1044
1044
1045
bitrate : number, optional
1045
1046
Specifies the number of bits used per second in the compressed
1046
1047
movie, in kilobits per second. A higher number means a higher
1047
1048
quality movie, but at the cost of increased file size. If ``None``,
1048
- defaults to :rc:`animation.bitrate`.
1049
+ defaults to :rc:`animation.bitrate` = -1 .
1049
1050
1050
1051
extra_args : list, optional
1051
1052
List of extra string arguments to be passed to the underlying movie
@@ -1070,13 +1071,12 @@ class to use, such as 'ffmpeg'. If ``None``, defaults to
1070
1071
1071
1072
Notes
1072
1073
-----
1073
- fps, codec, bitrate, extra_args, metadata are used to
1074
- construct a :class:`MovieWriter` instance and can only be
1075
- passed if `writer` is a string. If they are passed as
1076
- non-`None` and ``writer`` is a :class:`MovieWriter`, a
1077
- `RuntimeError` will be raised.
1074
+ *fps*, *codec*, *bitrate*, *extra_args* and *metadata* are used to
1075
+ construct a `.MovieWriter` instance and can only be passed if
1076
+ *writer* is a string. If they are passed as non-*None* and *writer*
1077
+ is a `.MovieWriter`, a `RuntimeError` will be raised.
1078
1078
1079
- '''
1079
+ """
1080
1080
# If the writer is None, use the rc param to find the name of the one
1081
1081
# to use
1082
1082
if writer is None :
@@ -1194,12 +1194,12 @@ def _step(self, *args):
1194
1194
return False
1195
1195
1196
1196
def new_frame_seq (self ):
1197
- '''Creates a new sequence of frame information.'''
1197
+ """Return a new sequence of frame information."""
1198
1198
# Default implementation is just an iterator over self._framedata
1199
1199
return iter (self ._framedata )
1200
1200
1201
1201
def new_saved_frame_seq (self ):
1202
- '''Creates a new sequence of saved/cached frame information.'''
1202
+ """Return a new sequence of saved/cached frame information."""
1203
1203
# Default is the same as the regular frame sequence
1204
1204
return self .new_frame_seq ()
1205
1205
@@ -1293,14 +1293,30 @@ def _end_redraw(self, evt):
1293
1293
self ._handle_resize )
1294
1294
1295
1295
def to_html5_video (self , embed_limit = None ):
1296
- '''Returns animation as an HTML5 video tag.
1296
+ """
1297
+ Convert the animation to an HTML5 ``<video>`` tag.
1297
1298
1298
1299
This saves the animation as an h264 video, encoded in base64
1299
1300
directly into the HTML5 video tag. This respects the rc parameters
1300
1301
for the writer as well as the bitrate. This also makes use of the
1301
1302
``interval`` to control the speed, and uses the ``repeat``
1302
1303
parameter to decide whether to loop.
1303
- '''
1304
+
1305
+ Parameters
1306
+ ----------
1307
+ embed_limit : float, optional
1308
+ Limit, in MB, of the returned animation. No animation is created
1309
+ if the limit is exceeded.
1310
+ Defaults to :rc:`animation.embed_limit` = 20.0.
1311
+
1312
+ Returns
1313
+ -------
1314
+ video_tag : str
1315
+ An HTML5 video tag with the animation embedded as base64 encoded
1316
+ h264 video.
1317
+ If the *embed_limit* is exceeded, this returns the string
1318
+ "Video too large to embed."
1319
+ """
1304
1320
VIDEO_TAG = r'''<video {size} {options}>
1305
1321
<source type="video/mp4" src="data:video/mp4;base64,{video}">
1306
1322
Your browser does not support the video tag.
@@ -1550,8 +1566,8 @@ def _draw_frame(self, artists):
1550
1566
1551
1567
1552
1568
class FuncAnimation (TimedAnimation ):
1553
- '''
1554
- Makes an animation by repeatedly calling a function `` func`` .
1569
+ """
1570
+ Makes an animation by repeatedly calling a function * func* .
1555
1571
1556
1572
Parameters
1557
1573
----------
@@ -1561,26 +1577,32 @@ class FuncAnimation(TimedAnimation):
1561
1577
1562
1578
func : callable
1563
1579
The function to call at each frame. The first argument will
1564
- be the next value in `` frames`` . Any additional positional
1565
- arguments can be supplied via the `` fargs`` parameter.
1580
+ be the next value in * frames* . Any additional positional
1581
+ arguments can be supplied via the * fargs* parameter.
1566
1582
1567
1583
The required signature is::
1568
1584
1569
- def func(frame, *fargs) -> iterable_of_artists:
1585
+ def func(frame, *fargs) -> iterable_of_artists
1586
+
1587
+ If ``blit == True``, *func* must return an iterable of all artists
1588
+ that were modified or created. This information is used by the blitting
1589
+ algorithm to determine which parts of the figure have to be updated.
1590
+ The return value is unused if ``blit == False`` and may be omitted in
1591
+ that case.
1570
1592
1571
1593
frames : iterable, int, generator function, or None, optional
1572
- Source of data to pass `` func`` and each frame of the animation
1594
+ Source of data to pass * func* and each frame of the animation
1573
1595
1574
- If an iterable, then simply use the values provided. If the
1575
- iterable has a length, it will override the `` save_count`` kwarg.
1596
+ - If an iterable, then simply use the values provided. If the
1597
+ iterable has a length, it will override the * save_count* kwarg.
1576
1598
1577
- If an integer, then equivalent to passing ``range(frames)``
1599
+ - If an integer, then equivalent to passing ``range(frames)``
1578
1600
1579
- If a generator function, then must have the signature::
1601
+ - If a generator function, then must have the signature::
1580
1602
1581
- def gen_function() -> obj:
1603
+ def gen_function() -> obj
1582
1604
1583
- If `` None`` , then equivalent to passing ``itertools.count``.
1605
+ - If * None* , then equivalent to passing ``itertools.count``.
1584
1606
1585
1607
In all of these cases, the values in *frames* is simply passed through
1586
1608
to the user-supplied *func* and thus can be of any type.
@@ -1591,12 +1613,15 @@ def gen_function() -> obj:
1591
1613
will be used. This function will be called once before the
1592
1614
first frame.
1593
1615
1594
- If ``blit == True``, ``init_func`` must return an iterable of artists
1595
- to be re-drawn.
1596
-
1597
1616
The required signature is::
1598
1617
1599
- def init_func() -> iterable_of_artists:
1618
+ def init_func() -> iterable_of_artists
1619
+
1620
+ If ``blit == True``, *init_func* must return an iterable of artists
1621
+ to be re-drawn. This information is used by the blitting
1622
+ algorithm to determine which parts of the figure have to be updated.
1623
+ The return value is unused if ``blit == False`` and may be omitted in
1624
+ that case.
1600
1625
1601
1626
fargs : tuple or None, optional
1602
1627
Additional arguments to pass to each call to *func*.
@@ -1609,19 +1634,19 @@ def init_func() -> iterable_of_artists:
1609
1634
1610
1635
repeat_delay : number, optional
1611
1636
If the animation in repeated, adds a delay in milliseconds
1612
- before repeating the animation. Defaults to `` None`` .
1637
+ before repeating the animation. Defaults to * None* .
1613
1638
1614
1639
repeat : bool, optional
1615
1640
Controls whether the animation should repeat when the sequence
1616
- of frames is completed. Defaults to `` True`` .
1641
+
CB27
of frames is completed. Defaults to * True* .
1617
1642
1618
1643
blit : bool, optional
1619
1644
Controls whether blitting is used to optimize drawing. Note: when using
1620
1645
blitting any animated artists will be drawn according to their zorder.
1621
1646
However, they will be drawn on top of any previous artists, regardless
1622
- of their zorder. Defaults to ``False``.
1647
+ of their zorder. Defaults to *False*.
1648
+ """
1623
1649
1624
- '''
1625
1650
def __init__ (self , fig , func , frames = None , init_func = None , fargs = None ,
1626
1651
save_count = None , ** kwargs ):
1627
1652
if fargs :
0 commit comments