10000 Merge pull request #21969 from meeseeksmachine/auto-backport-of-pr-21… · matplotlib/matplotlib@650d01c · GitHub
[go: up one dir, main page]

Skip to content

Commit 650d01c

Browse files
authored
Merge pull request #21969 from meeseeksmachine/auto-backport-of-pr-21948-on-v3.5.x
Backport PR #21948 on branch v3.5.x (Distinguish AbstractMovieWriter and MovieWriter in docs.)
2 parents 623298d + 0f997cd commit 650d01c

File tree

2 files changed

+21
-21
lines changed

2 files changed

+21
-21
lines changed

doc/api/animation_api.rst

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,9 @@ supported.
5959
The inner workings of `FuncAnimation` is more-or-less::
6060

6161
for d in frames:
62-
artists = func(d, *fargs)
63-
fig.canvas.draw_idle()
64-
fig.canvas.start_event_loop(interval)
62+
artists = func(d, *fargs)
63+
fig.canvas.draw_idle()
64+
fig.canvas.start_event_loop(interval)
6565

6666
with details to handle 'blitting' (to dramatically improve the live
6767
performance), to be non-blocking, not repeatedly start/stop the GUI
@@ -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 10000 . 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