-
Notifications
You must be signed in to change notification settings - Fork 60
Expand file tree
/
Copy pathmatplotlib.animation.FuncAnimation.html
More file actions
279 lines (254 loc) · 18.8 KB
/
matplotlib.animation.FuncAnimation.html
File metadata and controls
279 lines (254 loc) · 18.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="X-UA-Compatible" content="IE=Edge" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>matplotlib.animation.FuncAnimation — Matplotlib 3.4.1 documentation</title>
<link rel="stylesheet" href="../../_static/mpl.css?v3.4.1-3-gc6d08c6a8b-dirty" type="text/css" />
<link rel="stylesheet" href="../../_static/pygments.css" type="text/css" />
<link rel="stylesheet" type="text/css" href="../../_static/graphviz.css" />
<link rel="stylesheet" type="text/css" href="../../_static/plot_directive.css" />
<link rel="stylesheet" type="text/css" href="../../_static/copybutton.css" />
<link rel="stylesheet" type="text/css" href="../../_static/gallery.css" />
<link rel="stylesheet" type="text/css" href="../../_static/gallery-binder.css" />
<link rel="stylesheet" type="text/css" href="../../_static/gallery-dataframe.css" />
<script id="documentation_options" data-url_root="../../" src="../../_static/documentation_options.js"></script>
<script src="../../_static/jquery.js"></script>
<script src="../../_static/underscore.js"></script>
<script src="../../_static/doctools.js"></script>
<script src="../../_static/language_data.js"></script>
<script src="../../_static/clipboard.min.js"></script>
<script src="../../_static/copybutton.js"></script>
<script async="async" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.7/latest.js?config=TeX-AMS-MML_HTMLorMML"></script>
<link rel="search" type="application/opensearchdescription+xml"
title="Search within Matplotlib 3.4.1 documentation"
href="../../_static/opensearch.xml"/>
<link rel="shortcut icon" href="../../_static/favicon.ico"/>
<link rel="index" title="Index" href="../../genindex.html" />
<link rel="search" title="Search" href="../../search.html" />
<link rel="next" title="matplotlib.animation.ArtistAnimation" href="matplotlib.animation.ArtistAnimation.html" />
<link rel="prev" title="matplotlib.animation.Animation" href="matplotlib.animation.Animation.html" />
<link rel="top" title="Matplotlib 3.4.1 documentation" href="#" />
<link rel="canonical" href="https://matplotlib.org/stable/api/_as_gen/matplotlib.animation.FuncAnimation.html" />
<link rel="stylesheet" href="../../_static/custom.css" type="text/css" />
<meta name="viewport" content="width=device-width, initial-scale=0.9, maximum-scale=0.9" />
<script data-domain="matplotlib.org" defer="defer" src="https://views.scientific-python.org/js/script.js"></script>
</head><body>
<div id="unreleased-message"> You are reading an old version of the documentation (v3.4.1). For the latest version see <a href="https://matplotlib.org/stable/api/_as_gen/matplotlib.animation.FuncAnimation.html">https://matplotlib.org/stable/api/_as_gen/matplotlib.animation.FuncAnimation.html</a></div>
<!--
<div id="annc-banner">
</div>
-->
<div style="background-color: white; text-align: left; padding: 10px 10px 15px 15px; position: relative;">
<a href="../../index.html">
<div style="float: left; position: absolute; width: 496px; bottom: 0; padding-bottom: 24px"><span style="float: right; color: #789; background: white">Version 3.4.1</span></div>
<img src="../../_static/logo2_compressed.svg" height="125px" border="0" alt="matplotlib"/></a>
<!-- The "Fork me on github" ribbon -->
<div id="forkongithub"><a href="https://github.com/matplotlib/matplotlib">Fork me on GitHub</a></div>
</div>
<nav class="main-nav">
<ul>
<li><a href="../../users/installing.html">Installation</a></li>
<li><a href="../../contents.html">Documentation</a></li>
<li><a href="../../gallery/index.html">Examples</a></li>
<li><a href="../../tutorials/index.html">Tutorials</a></li>
<li><a href="../../devel/index.html">Contributing</a></li>
<li class="nav-right">
<form class="search" action="../../search.html" method="get">
<input type="text" name="q" aria-labelledby="searchlabel" placeholder="Search"/>
</form>
</li>
</ul>
</nav>
<div class="related" role="navigation" aria-label="related navigation">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="../../genindex.html" title="General Index"
accesskey="I">index</a></li>
<li class="right" >
<a href="../../py-modindex.html" title="Python Module Index"
>modules</a> |</li>
<li class="right" >
<a href="matplotlib.animation.ArtistAnimation.html" title="matplotlib.animation.ArtistAnimation"
accesskey="N">next</a> |</li>
<li class="right" >
<a href="matplotlib.animation.Animation.html" title="matplotlib.animation.Animation"
accesskey="P">previous</a> |</li>
<li><a href="../../index.html">home</a>| </li>
<li><a href="../../contents.html">contents</a> »</li>
<li class="nav-item nav-item-1"><a href="../index.html" >API Overview</a> »</li>
<li class="nav-item nav-item-2"><a href="../animation_api.html" accesskey="U"><code class="docutils literal notranslate"><span class="pre">matplotlib.animation</span></code></a> »</li>
<li class="nav-item nav-item-this"><a href="">matplotlib.animation.FuncAnimation</a></li>
</ul>
</div>
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
<div class="sphinxsidebarwrapper">
<div id="sidebar-pagesource" role="note" aria-label="source link"
style="margin-top: 1.5em; padding-top: 0.1em; border-top: 1px solid #86989b">
<a href="../../_sources/api/_as_gen/matplotlib.animation.FuncAnimation.rst.txt"
style="color: #c0c0c0" rel="nofollow">Show Page Source</a>
</div>
</div>
</div>
<div class="document">
<div class="documentwrapper">
<div class="bodywrapper">
<div class="body" role="main">
<div class="section" id="matplotlib-animation-funcanimation">
<h1>matplotlib.animation.FuncAnimation<a class="headerlink" href="#matplotlib-animation-funcanimation" title="Permalink to this headline">¶</a></h1>
<dl class="py class">
<dt id="matplotlib.animation.FuncAnimation">
<em class="property">class </em><code class="descclassname">matplotlib.animation.</code><code class="descname">FuncAnimation</code><span class="sig-paren">(</span><em><span class="n">fig</span></em>, <em><span class="n">func</span></em>, <em><span class="n">frames</span><span class="o">=</span><span class="default_value">None</span></em>, <em><span class="n">init_func</span><span class="o">=</span><span class="default_value">None</span></em>, <em><span class="n">fargs</span><span class="o">=</span><span class="default_value">None</span></em>, <em><span class="n">save_count</span><span class="o">=</span><span class="default_value">None</span></em>, <em><span class="o">*</span></em>, <em><span class="n">cache_frame_data</span><span class="o">=</span><span class="default_value">True</span></em>, <em><span class="o">**</span><span class="n">kwargs</span></em><span class="sig-paren">)</span><a class="reference internal" href="../../_modules/matplotlib/animation.html#FuncAnimation"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#matplotlib.animation.FuncAnimation" title="Permalink to this definition">¶</a></dt>
<dd><p>Makes an animation by repeatedly calling a function <em>func</em>.</p>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">You must store the created Animation in a variable that lives as long
as the animation should run. Otherwise, the Animation object will be
garbage-collected and the animation stops.</p>
</div>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><dl class="first last docutils">
<dt><strong>fig</strong><span class="classifier"><a class="reference internal" href="../figure_api.html#matplotlib.figure.Figure" title="matplotlib.figure.Figure"><code class="xref py py-obj docutils literal notranslate"><span class="pre">Figure</span></code></a></span></dt><dd><p>The figure object used to get needed events, such as draw or resize.</p>
</dd>
<dt><strong>func</strong><span class="classifier">callable</span></dt><dd><p>The function to call at each frame. The first argument will
be the next value in <em>frames</em>. Any additional positional
arguments can be supplied via the <em>fargs</em> parameter.</p>
<p>The required signature is:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="k">def</span> <span class="nf">func</span><span class="p">(</span><span class="n">frame</span><span class="p">,</span> <span class="o">*</span><span class="n">fargs</span><span class="p">)</span> <span class="o">-></span> <span class="n">iterable_of_artists</span>
</pre></div>
</div>
<p>If <code class="docutils literal notranslate"><span class="pre">blit</span> <span class="pre">==</span> <span class="pre">True</span></code>, <em>func</em> must return an iterable of all artists
that were modified or created. This information is used by the blitting
algorithm to determine which parts of the figure have to be updated.
The return value is unused if <code class="docutils literal notranslate"><span class="pre">blit</span> <span class="pre">==</span> <span class="pre">False</span></code> and may be omitted in
that case.</p>
</dd>
<dt><strong>frames</strong><span class="classifier">iterable, int, generator function, or None, optional</span></dt><dd><p>Source of data to pass <em>func</em> and each frame of the animation</p>
<ul>
<li><p class="first">If an iterable, then simply use the values provided. If the
iterable has a length, it will override the <em>save_count</em> kwarg.</p>
</li>
<li><p class="first">If an integer, then equivalent to passing <code class="docutils literal notranslate"><span class="pre">range(frames)</span></code></p>
</li>
<li><p class="first">If a generator function, then must have the signature:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="k">def</span> <span class="nf">gen_function</span><span class="p">()</span> <span class="o">-></span> <span class="n">obj</span>
</pre></div>
</div>
</li>
<li><p class="first">If <em>None</em>, then equivalent to passing <code class="docutils literal notranslate"><span class="pre">itertools.count</span></code>.</p>
</li>
</ul>
<p>In all of these cases, the values in <em>frames</em> is simply passed through
to the user-supplied <em>func</em> and thus can be of any type.</p>
</dd>
<dt><strong>init_func</strong><span class="classifier">callable, optional</span></dt><dd><p>A function used to draw a clear frame. If not given, the results of
drawing from the first item in the frames sequence will be used. This
function will be called once before the first frame.</p>
<p>The required signature is:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="k">def</span> <span class="nf">init_func</span><span class="p">()</span> <span class="o">-></span> <span class="n">iterable_of_artists</span>
</pre></div>
</div>
<p>If <code class="docutils literal notranslate"><span class="pre">blit</span> <span class="pre">==</span> <span class="pre">True</span></code>, <em>init_func</em> must return an iterable of artists
to be re-drawn. This information is used by the blitting algorithm to
determine which parts of the figure have to be updated. The return
value is unused if <code class="docutils literal notranslate"><span class="pre">blit</span> <span class="pre">==</span> <span class="pre">False</span></code> and may be omitted in that case.</p>
</dd>
<dt><strong>fargs</strong><span class="classifier">tuple or None, optional</span></dt><dd><p>Additional arguments to pass to each call to <em>func</em>.</p>
</dd>
<dt><strong>save_count</strong><span class="classifier">int, default: 100</span></dt><dd><p>Fallback for the number of values from <em>frames</em> to cache. This is
only used if the number of frames cannot be inferred from <em>frames</em>,
i.e. when it's an iterator without length or a generator.</p>
</dd>
<dt><strong>interval</strong><span class="classifier">int, default: 200</span></dt><dd><p>Delay between frames in milliseconds.</p>
</dd>
<dt><strong>repeat_delay</strong><span class="classifier">int, default: 0</span></dt><dd><p>The delay in milliseconds between consecutive animation runs, if
<em>repeat</em> is True.</p>
</dd>
<dt><strong>repeat</strong><span class="classifier">bool, default: True</span></dt><dd><p>Whether the animation repeats when the sequence of frames is completed.</p>
</dd>
<dt><strong>blit</strong><span class="classifier">bool, default: False</span></dt><dd><p>Whether blitting is used to optimize drawing. Note: when using
blitting, any animated artists will be drawn according to their zorder;
however, they will be drawn on top of any previous artists, regardless
of their zorder.</p>
</dd>
<dt><strong>cache_frame_data</strong><span class="classifier">bool, default: True</span></dt><dd><p>Whether frame data is cached. Disabling cache might be helpful when
frames contain large objects.</p>
</dd>
</dl>
</td>
</tr>
</tbody>
</table>
<dl class="py method">
<dt id="matplotlib.animation.FuncAnimation.__init__">
<code class="descname">__init__</code><span class="sig-paren">(</span><em><span class="n">self</span></em>, <em><span class="n">fig</span></em>, <em><span class="n">func</span></em>, <em><span class="n">frames</span><span class="o">=</span><span class="default_value">None</span></em>, <em><span class="n">init_func</span><span class="o">=</span><span class="default_value">None</span></em>, <em><span class="n">fargs</span><span class="o">=</span><span class="default_value">None</span></em>, <em><span class="n">save_count</span><span class="o">=</span><span class="default_value">None</span></em>, <em><span class="o">*</span></em>, <em><span class="n">cache_frame_data</span><span class="o">=</span><span class="default_value">True</span></em>, <em><span class="o">**</span><span class="n">kwargs</span></em><span class="sig-paren">)</span><a class="reference internal" href="../../_modules/matplotlib/animation.html#FuncAnimation.__init__"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#matplotlib.animation.FuncAnimation.__init__" title="Permalink to this definition">¶</a></dt>
<dd><p>Initialize self. See help(type(self)) for accurate signature.</p>
</dd></dl>
<p class="rubric">Methods</p>
<table border="1" class="longtable docutils align-default">
<colgroup>
<col width="10%" />
<col width="90%" />
</colgroup>
<tbody valign="top">
<tr class="row-odd"><td><a class="reference internal" href="#matplotlib.animation.FuncAnimation.__init__" title="matplotlib.animation.FuncAnimation.__init__"><code class="xref py py-obj docutils literal notranslate"><span class="pre">__init__</span></code></a>(self, fig, func[, frames, ...])</td>
<td>Initialize self.</td>
</tr>
<tr class="row-even"><td><a class="reference internal" href="#matplotlib.animation.FuncAnimation.new_frame_seq" title="matplotlib.animation.FuncAnimation.new_frame_seq"><code class="xref py py-obj docutils literal notranslate"><span class="pre">new_frame_seq</span></code></a>(self)</td>
<td>Return a new sequence of frame information.</td>
</tr>
<tr class="row-odd"><td><a class="reference internal" href="#matplotlib.animation.FuncAnimation.new_saved_frame_seq" title="matplotlib.animation.FuncAnimation.new_saved_frame_seq"><code class="xref py py-obj docutils literal notranslate"><span class="pre">new_saved_frame_seq</span></code></a>(self)</td>
<td>Return a new sequence of saved/cached frame information.</td>
</tr>
<tr class="row-even"><td><code class="xref py py-obj docutils literal notranslate"><span class="pre">pause</span></code>(self)</td>
<td>Pause the animation.</td>
</tr>
<tr class="row-odd"><td><code class="xref py py-obj docutils literal notranslate"><span class="pre">resume</span></code>(self)</td>
<td>Resume the animation.</td>
</tr>
<tr class="row-even"><td><code class="xref py py-obj docutils literal notranslate"><span class="pre">save</span></code>(self, filename[, writer, fps, dpi, ...])</td>
<td>Save the animation as a movie file by drawing every frame.</td>
</tr>
<tr class="row-odd"><td><code class="xref py py-obj docutils literal notranslate"><span class="pre">to_html5_video</span></code>(self[, embed_limit])</td>
<td>Convert the animation to an HTML5 <code class="docutils literal notranslate"><span class="pre"><video></span></code> tag.</td>
</tr>
<tr class="row-even"><td><code class="xref py py-obj docutils literal notranslate"><span class="pre">to_jshtml</span></code>(self[, fps, embed_frames, ...])</td>
<td>Generate HTML representation of the animation</td>
</tr>
</tbody>
</table>
<dl class="py method">
<dt id="matplotlib.animation.FuncAnimation.new_frame_seq">
<code class="descname">new_frame_seq</code><span class="sig-paren">(</span><em><span class="n">self</span></em><span class="sig-paren">)</span><a class="reference internal" href="../../_modules/matplotlib/animation.html#FuncAnimation.new_frame_seq"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#matplotlib.animation.FuncAnimation.new_frame_seq" title="Permalink to this definition">¶</a></dt>
<dd><p>Return a new sequence of frame information.</p>
</dd></dl>
<dl class="py method">
<dt id="matplotlib.animation.FuncAnimation.new_saved_frame_seq">
<code class="descname">new_saved_frame_seq</code><span class="sig-paren">(</span><em><span class="n">self</span></em><span class="sig-paren">)</span><a class="reference internal" href="../../_modules/matplotlib/animation.html#FuncAnimation.new_saved_frame_seq"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#matplotlib.animation.FuncAnimation.new_saved_frame_seq" title="Permalink to this definition">¶</a></dt>
<dd><p>Return a new sequence of saved/cached frame information.</p>
</dd></dl>
</dd></dl>
</div>
</div>
</div>
</div>
<div class="clearer"></div>
</div>
<footer>
<div class="footer">
© Copyright 2002 - 2012 John Hunter, Darren Dale, Eric Firing, Michael Droettboom and the Matplotlib development team; 2012 - 2021 The Matplotlib development team.
<br />
Last updated on Mar 31, 2021.
Created using
<a href="http://sphinx-doc.org/">Sphinx</a> 3.2.1.
Doc version v3.4.1-3-gc6d08c6a8b-dirty.
</div>
</footer>
</body>
</html>