8000 Distinguish AbstractMovieWriter and MovieWriter in docs. · matplotlib/matplotlib@909d5b8 · GitHub
[go: up one dir, main page]

Skip to content 10000

Commit 909d5b8

Browse files
committed
Distinguish AbstractMovieWriter and MovieWriter in docs.
Some docs of AbstractMovieWriter are still written as if referring to MovieWriter (which could be better named PipeMovieWriter, i.e. writers that pipe frame data to a running subprocess). This probably dates back to when AbstractMovieWriter was not a thing yet. Fix that.
1 parent 085fdd0 commit 909d5b8

File tree

2 files changed

+18
-18
lines changed

2 files changed

+18
-18
lines changed

doc/api/animation_api.rst

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -211,16 +211,18 @@ debug.
211211
FFMpegFileWriter
212212
ImageMagickFileWriter
213213

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

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

225227
moviewriter = MovieWriter(...)
226228
moviewriter.setup(fig, 'my_movie.ext', dpi=100)
@@ -230,14 +232,14 @@ file to disk. For example ::
230232
moviewriter.finish()
231233

232234
If using the writer classes directly (not through `Animation.save`), it is
233-
strongly encouraged to use the `~MovieWriter.saving` context manager ::
235+
strongly encouraged to use the `~.AbstractMovieWriter.saving` context manager::
234236

235237
with moviewriter.saving(fig, 'myfile.mp4', dpi=100):
236238
for j in range(n):
237239
update_figure(j)
238240
moviewriter.grab_frame()
239241

240-
to ensures that setup and cleanup are performed as necessary.
242+
to ensure that setup and cleanup are performed as necessary.
241243

242244
Examples
243245
--------

lib/matplotlib/animation.py

Lines 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