Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit ee3cb9a

Browse filesBrowse files
authored
Merge pull request #21948 from anntzer/animdoc
Distinguish AbstractMovieWriter and MovieWriter in docs.
2 parents 2466b3b + 470f8d3 commit ee3cb9a
Copy full SHA for ee3cb9a

File tree

2 files changed

+21
-21
lines changed
Filter options

2 files changed

+21
-21
lines changed

‎doc/api/animation_api.rst

Copy file name to clipboardExpand all lines: doc/api/animation_api.rst
+16-14Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,9 @@ supported.
5151
The inner workings of `FuncAnimation` is more-or-less::
5252

5353
for d in frames:
54-
artists = func(d, *fargs)
55-
fig.canvas.draw_idle()
56-
fig.canvas.start_event_loop(interval)
54+
artists = func(d, *fargs)
55+
fig.canvas.draw_idle()
56+
fig.canvas.start_event_loop(interval)
5757

5858
with details to handle 'blitting' (to dramatically improve the live
5959
performance), to be non-blocking, not repeatedly start/stop the GUI
@@ -207,16 +207,18 @@ debug.
207207
FFMpegFileWriter
208208
ImageMagickFileWriter
209209

210-
Fundamentally, a `MovieWriter` provides a way to grab sequential frames
211-
from the same underlying `~matplotlib.figure.Figure` object. The base
212-
class `MovieWriter` implements 3 methods and a context manager. The
213-
only difference between the pipe-based and file-based writers is in the
214-
arguments to their respective ``setup`` methods.
210+
The writer classes provide a way to grab sequential frames from the same
211+
underlying `~matplotlib.figure.Figure`. They all provide three methods that
212+
must be called in sequence:
215213

216-
The ``setup()`` method is used to prepare the writer (possibly opening
217-
a pipe), successive calls to ``grab_frame()`` capture a single frame
218-
at a time and ``finish()`` finalizes the movie and writes the output
219-
file to disk. For example ::
214+
- `~.AbstractMovieWriter.setup` prepares the writer (e.g. opening a pipe).
215+
Pipe-based and file-based writers take different arguments to ``setup()``.
216+
- `~.AbstractMovieWriter.grab_frame` can then be called as often as
217+
needed to capture a single frame at a time
218+
- `~.AbstractMovieWriter.finish` finalizes the movie and writes the output
219+
file to disk.
220+
221+
Example::
220222

221223
moviewriter = MovieWriter(...)
222224
moviewriter.setup(fig, 'my_movie.ext', dpi=100)
@@ -226,14 +228,14 @@ file to disk. For example ::
226228
moviewriter.finish()
227229

228230
If using the writer classes directly (not through `Animation.save`), it is
229-
strongly encouraged to use the `~MovieWriter.saving` context manager ::
231+
strongly encouraged to use the `~.AbstractMovieWriter.saving` context manager::
230232

231233
with moviewriter.saving(fig, 'myfile.mp4', dpi=100):
232234
for j in range(n):
233235
update_figure(j)
234236
moviewriter.grab_frame()
235237

236-
to ensures that setup and cleanup are performed as necessary.
238+
to ensure that setup and cleanup are performed as necessary.
237239

238240
Examples
239241
--------

‎lib/matplotlib/animation.py

Copy file name to clipboardExpand all lines: lib/matplotlib/animation.py
+5-7Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -156,19 +156,17 @@ def __getitem__(self, name):
156156

157157
class AbstractMovieWriter(abc.ABC):
158158
"""
159-
Abstract base class for writing movies. Fundamentally, what a MovieWriter
160-
does is provide is a way to grab frames by calling grab_frame().
159+
Abstract base class for writing movies, providing a way to grab frames by
160+
calling `~AbstractMovieWriter.grab_frame`.
161161
162-
setup() is called to start the process and finish() is called afterwards.
163-
164-
This class is set up to provide for writing movie frame data to a pipe.
165-
saving() is provided as a context manager to facilitate this process as::
162+
`setup` is called to start the process and `finish` is called afterwards.
163+
`saving` is provided as a context manager to facilitate this process as ::
166164
167165
with moviewriter.saving(fig, outfile='myfile.mp4', dpi=100):
168166
# Iterate over frames
169167
moviewriter.grab_frame(**savefig_kwargs)
170168
171-
The use of the context manager ensures that setup() and finish() are
169+
The use of the context manager ensures that `setup` and `finish` are
172170
performed as necessary.
173171
174172
An instance of a concrete subclass of this class can be given as the

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.