Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 6ee361b

Browse files
authored
Merge pull request #16218 from anntzer/adoc
Cleanup animation docs.
2 parents c0bf2ef + e958ea7 commit 6ee361b

File tree

1 file changed

+75
-109
lines changed

1 file changed

+75
-109
lines changed

lib/matplotlib/animation.py

Lines changed: 75 additions & 109 deletions
Original file line numberDiff line numberDiff line change
@@ -205,12 +205,12 @@ def setup(self, fig, outfile, dpi=None):
205205
Parameters
206206
----------
207207
fig : `~matplotlib.figure.Figure`
208-
The figure object that contains the information for frames
208+
The figure object that contains the information for frames.
209209
outfile : str
210-
The filename of the resulting movie file
211-
dpi : int, optional
210+
The filename of the resulting movie file.
211+
dpi : int, optional, default: ``fig.dpi``
212212
The DPI (or resolution) for the file. This controls the size
213-
in pixels of the resulting movie file. Default is ``fig.dpi``.
213+
in pixels of the resulting movie file.
214214
"""
215215
self.outfile = outfile
216216
self.fig = fig
@@ -338,19 +338,7 @@ def _adjust_frame_size(self):
338338
return w, h
339339

340340
def setup(self, fig, outfile, dpi=None):
341-
"""
342-
Perform setup for writing the movie file.
343-
344-
Parameters
345-
----------
346-
fig : `~matplotlib.figure.Figure`
347-
The figure object that contains the information for frames
348-
outfile : str
349-
The filename of the resulting movie file
350-
dpi : int, optional
351-
The DPI (or resolution) for the file. This controls the size
352-
in pixels of the resulting movie file. Default is fig.dpi.
353-
"""
341+
# docstring inherited
354342
super().setup(fig, outfile, dpi=dpi)
355343
self._w, self._h = self._adjust_frame_size()
356344
# Run here so that grab_frame() can write the data to a pipe. This
@@ -896,25 +884,23 @@ class Animation:
896884
Parameters
897885
----------
898886
fig : `~matplotlib.figure.Figure`
899-
The figure object that is used to get draw, resize, and any
900-
other needed events.
887+
The figure object used to get needed events, such as draw or resize.
901888
902889
event_source : object, optional
903-
A class that can run a callback when desired events
904-
are generated, as well as be stopped and started.
890+
A class that can run a callback when desired events
891+
are generated, as well as be stopped and started.
905892
906-
Examples include timers (see :class:`TimedAnimation`) and file
907-
system notifications.
893+
Examples include timers (see `TimedAnimation`) and file
894+
system notifications.
908895
909-
blit : bool, optional
910-
controls whether blitting is used to optimize drawing. Defaults
911-
to ``False``.
896+
blit : bool, default: False
897+
Whether blitting is used to optimize drawing.
912898
913899
See Also
914900
--------
915901
FuncAnimation, ArtistAnimation
916-
917902
"""
903+
918904
def __init__(self, fig, event_source=None, blit=False):
919905
self._fig = fig
920906
# Disables blitting for backends that don't support it. This
@@ -1393,25 +1379,18 @@ class TimedAnimation(Animation):
13931379
Parameters
13941380
----------
13951381
fig : `~matplotlib.figure.Figure`
1396-
The figure object that is used to get draw, resize, and any
1397-
other needed events.
1398-
1399-
interval : number, optional
1400-
Delay between frames in milliseconds. Defaults to 200.
1401-
1402-
repeat_delay : number, optional
1403-
If the animation in repeated, adds a delay in milliseconds
1404-
before repeating the animation. Defaults to ``None``.
1405-
1406-
repeat : bool, optional
1407-
Controls whether the animation should repeat when the sequence
1408-
of frames is completed. Defaults to ``True``.
1409-
1410-
blit : bool, optional
1411-
Controls whether blitting is used to optimize drawing. Defaults
1412-
to ``False``.
1413-
1382+
The figure object used to get needed events, such as draw or resize.
1383+
interval : int, default: 200
1384+
Delay between frames in milliseconds.
1385+
repeat_delay : int, default: 0
1386+
The delay in milliseconds between consecutive animation runs, if
1387+
*repeat* is True.
1388+
repeat : bool, default: True
1389+
Whether the animation repeats when the sequence of frames is completed.
1390+
blit : bool, default: False
1391+
Whether blitting is used to optimize drawing.
14141392
"""
1393+
14151394
def __init__(self, fig, interval=200, repeat_delay=None, repeat=True,
14161395
event_source=None, *args, **kwargs):
14171396
# Store the timing information
@@ -1452,7 +1431,7 @@ def _step(self, *args):
14521431

14531432
def _stop(self, *args):
14541433
# If we stop in the middle of a loop delay (which is relatively likely
1455-
# given the potential pause here, remove the loop_delay callback as
1434+
# given the potential pause here), remove the loop_delay callback as
14561435
# well.
14571436
self.event_source.remove_callback(self._loop_delay)
14581437
Animation._stop(self)
@@ -1475,30 +1454,21 @@ class ArtistAnimation(TimedAnimation):
14751454
Parameters
14761455
----------
14771456
fig : `~matplotlib.figure.Figure`
1478-
The figure object that is used to get draw, resize, and any
1479-
other needed events.
1480-
1457+
The figure object used to get needed events, such as draw or resize.
14811458
artists : list
1482-
Each list entry a collection of artists that represent what
1483-
needs to be enabled on each frame. These will be disabled for
1484-
other frames.
1485-
1486-
interval : number, optional
1487-
Delay between frames in milliseconds. Defaults to 200.
1488-
1489-
repeat_delay : number, optional
1490-
If the animation in repeated, adds a delay in milliseconds
1491-
before repeating the animation. Defaults to ``None``.
1492-
1493-
repeat : bool, optional
1494-
Controls whether the animation should repeat when the sequence
1495-
of frames is completed. Defaults to ``True``.
1496-
1497-
blit : bool, optional
1498-
Controls whether blitting is used to optimize drawing. Defaults
1499-
to ``False``.
1500-
1459+
Each list entry is a collection of artists that are made visible on
1460+
the corresponding frame. Other artists are made invisible.
1461+
interval : int, default: 200
1462+
Delay between frames in milliseconds.
1463+
repeat_delay : int, default: 0
1464+
The delay in milliseconds between consecutive animation runs, if
1465+
*repeat* is True.
1466+
repeat : bool, default: True
1467+
Whether the animation repeats when the sequence of frames is completed.
1468+
blit : bool, default: False
1469+
Whether blitting is used to optimize drawing.
15011470
"""
1471+
15021472
def __init__(self, fig, artists, *args, **kwargs):
15031473
# Internal list of artists drawn in the most recent frame.
15041474
self._drawn_artists = []
@@ -1550,23 +1520,22 @@ class FuncAnimation(TimedAnimation):
15501520
Parameters
15511521
----------
15521522
fig : `~matplotlib.figure.Figure`
1553-
The figure object that is used to get draw, resize, and any
1554-
other needed events.
1523+
The figure object used to get needed events, such as draw or resize.
15551524
15561525
func : callable
1557-
The function to call at each frame. The first argument will
1558-
be the next value in *frames*. Any additional positional
1559-
arguments can be supplied via the *fargs* parameter.
1526+
The function to call at each frame. The first argument will
1527+
be the next value in *frames*. Any additional positional
1528+
arguments can be supplied via the *fargs* parameter.
15601529
1561-
The required signature is::
1530+
The required signature is::
15621531
1563-
def func(frame, *fargs) -> iterable_of_artists
1532+
def func(frame, *fargs) -> iterable_of_artists
15641533
1565-
If ``blit == True``, *func* must return an iterable of all artists
1566-
that were modified or created. This information is used by the blitting
1567-
algorithm to determine which parts of the figure have to be updated.
1568-
The return value is unused if ``blit == False`` and may be omitted in
1569-
that case.
1534+
If ``blit == True``, *func* must return an iterable of all artists
1535+
that were modified or created. This information is used by the blitting
1536+
algorithm to determine which parts of the figure have to be updated.
1537+
The return value is unused if ``blit == False`` and may be omitted in
1538+
that case.
15701539
15711540
frames : iterable, int, generator function, or None, optional
15721541
Source of data to pass *func* and each frame of the animation
@@ -1586,47 +1555,44 @@ def gen_function() -> obj
15861555
to the user-supplied *func* and thus can be of any type.
15871556
15881557
init_func : callable, optional
1589-
A function used to draw a clear frame. If not given, the
1590-
results of drawing from the first item in the frames sequence
1591-
will be used. This function will be called once before the
1592-
first frame.
1558+
A function used to draw a clear frame. If not given, the results of
1559+
drawing from the first item in the frames sequence will be used. This
1560+
function will be called once before the first frame.
15931561
1594-
The required signature is::
1562+
The required signature is::
15951563
1596-
def init_func() -> iterable_of_artists
1564+
def init_func() -> iterable_of_artists
15971565
1598-
If ``blit == True``, *init_func* must return an iterable of artists
1599-
to be re-drawn. This information is used by the blitting
1600-
algorithm to determine which parts of the figure have to be updated.
1601-
The return value is unused if ``blit == False`` and may be omitted in
1602-
that case.
1566+
If ``blit == True``, *init_func* must return an iterable of artists
1567+
to be re-drawn. This information is used by the blitting algorithm to
1568+
determine which parts of the figure have to be updated. The return
1569+
value is unused if ``blit == False`` and may be omitted in that case.
16031570
16041571
fargs : tuple or None, optional
1605-
Additional arguments to pass to each call to *func*.
1572+
Additional arguments to pass to each call to *func*.
16061573
16071574
save_count : int, optional
1608-
The number of values from *frames* to cache.
1575+
The number of values from *frames* to cache.
16091576
1610-
interval : number, optional
1611-
Delay between frames in milliseconds. Defaults to 200.
1577+
interval : int, default: 200
1578+
Delay between frames in milliseconds.
16121579
1613-
repeat_delay : number, optional
1614-
If the animation in repeated, adds a delay in milliseconds
1615-
before repeating the animation. Defaults to *None*.
1580+
repeat_delay : int, default: 0
1581+
The delay in milliseconds between consecutive animation runs, if
1582+
*repeat* is True.
16161583
1617-
repeat : bool, optional
1618-
Controls whether the animation should repeat when the sequence
1619-
of frames is completed. Defaults to *True*.
1584+
repeat : bool, default: True
1585+
Whether the animation repeats when the sequence of frames is completed.
16201586
1621-
blit : bool, optional
1622-
Controls whether blitting is used to optimize drawing. Note: when using
1623-
blitting any animated artists will be drawn according to their zorder.
1624-
However, they will be drawn on top of any previous artists, regardless
1625-
of their zorder. Defaults to *False*.
1587+
blit : bool, default: False
1588+
Whether blitting is used to optimize drawing. Note: when using
1589+
blitting, any animated artists will be drawn according to their zorder;
1590+
however, they will be drawn on top of any previous artists, regardless
1591+
of their zorder.
16261592
1627-
cache_frame_data : bool, optional
1628-
Controls whether frame data is cached. Defaults to *True*.
1629-
Disabling cache might be helpful when frames contain large objects.
1593+
cache_frame_data : bool, default: True
1594+
Whether frame data is cached. Disabling cache might be helpful when
1595+
frames contain large objects.
16301596
"""
16311597

16321598
def __init__(self, fig, func, frames=None, init_func=None, fargs=None,

0 commit comments

Comments
 (0)