Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
80d8dd8
DOC: partially numpydoc-ify animation module
tacaswell Dec 7, 2016
24c7aad
DOC: use auto summary in animation_api.rst
tacaswell Dec 8, 2016
e465fb7
DOC: start to add animation prose
tacaswell Dec 8, 2016
ff1e71e
DOC: address comments
tacaswell Dec 11, 2016
55017cd
DOC: re-work MovieWriter section a bit
tacaswell Dec 11, 2016
437386b
MNT: tweak MovieWriter.saving to be more cautious
tacaswell Dec 11, 2016
1a6c61c
DOC: address the rest of the comments
tacaswell Dec 11, 2016
8e8291c
DOC: Fix more typos and minor errors
tacaswell Dec 11, 2016
e3de3be
BUG: fix minpos handling and other log ticker problems
efiring Dec 9, 2016
8bdabcd
refactor LogFormatter classes for consistency, readability
efiring Dec 10, 2016
a8e7575
api_changes: add note about LogFormatter linthresh kwarg.
efiring Dec 10, 2016
aa36ec3
test for shared log axes
efiring Dec 10, 2016
93d09be
Merge pull request #7596 from anntzer/delay-fc-list-warning
QuLogic Dec 12, 2016
1a21bea
Merge pull request #7618 from samuelstjean/patch-1
tacaswell Dec 12, 2016
4c4779b
DOC: minor tweaks
tacaswell Dec 12, 2016
4177725
Merge pull request #7589 from tacaswell/doc_animation
dopplershift Dec 12, 2016
4d59447
Merge pull request #7598 from efiring/minpos_initial
tacaswell Dec 12, 2016
06dce26
API: convert string fontsize to points immediately
tacaswell Aug 30, 2016
2ddcc68
API: cache usetex value at text creation time
tacaswell Dec 3, 2016
23392f8
Merge pull request #7606 from tacaswell/mnt_more_paranoid_moviewriter…
efiring Dec 12, 2016
98e9fb2
STY: some whitespace cleanups
tacaswell Dec 3, 2016
bb37ab6
MNT: ensure that defaults are cached init
tacaswell Dec 3, 2016
a578628
STY: wrap long line
tacaswell Dec 4, 2016
b079583
MNT: remove None from value checks
tacaswell Dec 4, 2016
55c266c
MNT: set the family to rcParam value in init
tacaswell Dec 5, 2016
b6278e3
MNT: use else block to localize exceptions
tacaswell Dec 5, 2016
5f4eead
MNT: minor simplification
tacaswell Dec 12, 2016
f367003
Merge pull request #7007 from tacaswell/api_set_font_size_at_creation…
QuLogic Dec 12, 2016
bbe4fd8
Merge remote-tracking branch 'matplotlib/v2.x'
tacaswell Dec 13, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
DOC: address comments
  • Loading branch information
tacaswell committed Dec 11, 2016
commit ff1e71e31495e0fc87858c44228cf8bce8d5cb79
10 changes: 5 additions & 5 deletions doc/api/animation_api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ The easiest way to make a live animation in mpl is to use one of the
FuncAnimation
ArtistAnimation

In both cases it is critical to keep a reference to tho instance
In both cases it is critical to keep a reference to the instance
object. The animation is advanced by a timer (typically from the host
GUI framework) which the `Animation` object holds the only reference
to. If you do not hold a reference to the `Animation` object, it (and
Expand Down Expand Up @@ -115,9 +115,9 @@ artist at a global scope and let Python sort things out. For example ::
ax.set_ylim(-1, 1)
return ln,

def update(i):
xdata.append(i)
ydata.append(np.sin(i))
def update(frame):
xdata.append(frame)
ydata.append(np.sin(frame))
ln.set_data(xdata, ydata)
return ln,

Expand All @@ -128,7 +128,7 @@ artist at a global scope and let Python sort things out. For example ::

The second method is to us `functools.partial` to 'bind' artists to
function. A third method is to use closures to build up the required
artists and functions. A forth method is to create a class.
artists and functions. A fourth method is to create a class.



Expand Down
110 changes: 41 additions & 69 deletions lib/matplotlib/animation.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def adjusted_figsize(w, h, dpi, n):

# A registry for available MovieWriter classes
class MovieWriterRegistry(object):
'''Registry of of available writer classes by human readable name
'''Registry of available writer classes by human readable name
'''
def __init__(self):
self.avail = dict()
Expand Down Expand Up @@ -111,13 +111,14 @@ def list(self):
return list(self.avail.keys())

def is_available(self, name):
'''If given writer is available
'''Check if given writer is available by name

Parameters
----------
name : str

Returns
-------
available : bool
'''
self.ensure_not_dirty()
Expand All @@ -141,42 +142,19 @@ class MovieWriter(object):
Attributes
----------

frame_format : string
frame_format : str
The format used in writing frame data, defaults to 'rgba'

fig : `~matplotlib.figure.Figure`
The figure to capture data from.
This must be provided by the sub-classes

Examples
--------

Fundamentally, what a MovieWriter does is provide is a way to grab
frames by calling grab_frame(). setup() is called to start the
process and finish() is called afterwards ::

moviewriter = MovieWriter(...)
moveiewriter.setup()
for j in range(n):
update_figure(n)
moviewriter.grab_frame()
moviewriter.finish()


saving() is provided as a context manager to facilitate this process as::

with moviewriter.saving('myfile.mp4'):
# Iterate over frames
moviewriter.grab_frame()

The use of the context manager ensures that setup and cleanup are
performed as necessary.
This must be provided by the sub-classes.

'''

def __init__(self, fps=5, codec=None, bitrate=None, extra_args=None,
metadata=None):
'''
'''MovieWriter

Parameters
----------
fps: int
Expand Down Expand Up @@ -371,31 +349,28 @@ class FileMovieWriter(MovieWriter):
This must be sub-classed to be useful.
'''
def __init__(self, *args, **kwargs):
'''
Parameters
----------
fig : `matplotlib.Figure` instance
The figure object that contains the information for frames
outfile : string
The filename of the resulting movie file
dpi : int
The DPI (or resolution) for the file. This controls the size
in pixels of the resulting movie file.
frame_prefix : string, optional
The filename prefix to use for the temporary files. Defaults
to '_tmp'
clear_temp : bool
Specifies whether the temporary files should be deleted after
the movie is written. (Useful for debugging.) Defaults to True.

'''

MovieWriter.__init__(self, *args, **kwargs)
self.frame_format = rcParams['animation.frame_format']

def setup(self, fig, outfile, dpi, frame_prefix='_tmp', clear_temp=True):
'''
Perform setup for writing the movie file.
'''Perform setup for writing the movie file.

Parameters
----------
fig : matplotlib.figure.Figure
The figure to grab the rendered frames from.
outfile : str
The filename of the resulting movie file.
dpi : number
The dpi of the output file. This, with the figure size,
controls the size in pixels of the resulting movie file.
frame_prefix : str, optional
The filename prefix to use for temporary files. Defaults to
'_tmp'.
clear_temp : bool, optional
If the temporary files should be deleted after stitching
the final result. Setting this to `False` can be useful for
debugging. Defaults to `True`.

'''
self.fig = fig
Expand Down Expand Up @@ -541,7 +516,7 @@ def output_args(self):
# Combine FFMpeg options with pipe-based writing
@writers.register('ffmpeg')
class FFMpegWriter(MovieWriter, FFMpegBase):
'''Pipe based ffmpeg writer.
'''Pipe-based ffmpeg writer.

Frames are streamed directly to ffmpeg via a pipe and written in a single
pass.
Expand All @@ -562,7 +537,7 @@ def _args(self):
# Combine FFMpeg options with temp file-based writing
@writers.register('ffmpeg_file')
class FFMpegFileWriter(FileMovieWriter, FFMpegBase):
'''File based ffmpeg writer
'''File-based ffmpeg writer

Frames are written to temporary files on disk and then stitched
together at the end.
Expand Down Expand Up @@ -595,7 +570,7 @@ class AVConvBase(FFMpegBase):
# Combine AVConv options with pipe-based writing
@writers.register('avconv')
class AVConvWriter(AVConvBase, FFMpegWriter):
'''Pipe based avconv writer.
'''Pipe-based avconv writer.

Frames are streamed directly to avconv via a pipe and written in a single
pass.
Expand All @@ -605,7 +580,7 @@ class AVConvWriter(AVConvBase, FFMpegWriter):
# Combine AVConv options with file-based writing
@writers.register('avconv_file')
class AVConvFileWriter(AVConvBase, FFMpegFileWriter):
'''File based avconv writer
'''File-based avconv writer

Frames are written to temporary files on disk and then stitched
together at the end.
Expand Down Expand Up @@ -750,7 +725,7 @@ def isAvailable(cls):
# former.
@writers.register('imagemagick')
class ImageMagickWriter(ImageMagickBase, MovieWriter):
'''Pipe based animated gif
'''Pipe-based animated gif

Frames are streamed directly to ImageMagick via a pipe and written
in a single pass.
Expand All @@ -770,7 +745,7 @@ def _args(self):
# former.
@writers.register('imagemagick_file')
class ImageMagickFileWriter(ImageMagickBase, FileMovieWriter):
'''File based animated gif writer
'''File-based animated gif writer

Frames are written to temporary files on disk and then stitched
together at the end.
Expand Down Expand Up @@ -895,7 +870,7 @@ class to use, such as 'ffmpeg' or 'mencoder'. If `None`,
codec : str, optional
the video codec to be used. Not all codecs are supported by
a given :class:`MovieWriter`. If `None`,
default to ``rcParams['animation.codec']``
default to ``rcParams['animation.codec']``

bitrate : number, optional
specifies the amount of bits used per second in the
Expand Down Expand Up @@ -931,7 +906,7 @@ class to use, such as 'ffmpeg' or 'mencoder'. If `None`,
-----
fps, codec, bitrate, extra_args, metadata are used are used to
construct a :class:`MovieWriter` instance and can only be
passed if `writer` is a string. If they are pass as
passed if `writer` is a string. If they are passed as
non-`None` and ``writer`` is a :class:`MovieWriter`, a
`RuntimeError` will be raised.

Expand Down Expand Up @@ -1220,15 +1195,15 @@ class TimedAnimation(Animation):
other needed events.

interval : number, optional
Delay between frames. Defaults to 200
Delay between frames in milliseconds. Defaults to 200.

repeat_delay : number, optional
If the animation in repeated, adds a delay in milliseconds
before repeating the animation. Defaults to None

repeat: bool, optional
controls whether the animation should repeat when the sequence
of frames is completed.
of frames is completed. Defaults to `True`.

blit : bool, optional
controls whether blitting is used to optimize drawing. Defaults
Expand Down Expand Up @@ -1309,15 +1284,15 @@ class ArtistAnimation(TimedAnimation):
be disabled for other frames.

interval : number, optional
Delay between frames. Defaults to 200
Delay between frames in miliseconds. Defaults to 200.

repeat_delay : number, optional
If the animation in repeated, adds a delay in milliseconds
before repeating the animation. Defaults to None
before repeating the animation. Defaults to `None`.

repeat: bool, optional
controls whether the animation should repeat when the sequence
of frames is completed.
of frames is completed. Defaults to `True`.

blit : bool, optional
controls whether blitting is used to optimize drawing. Defaults
Expand Down Expand Up @@ -1381,7 +1356,6 @@ class FuncAnimation(TimedAnimation):
other needed events.

func : callable

The function to call at each frame. The first argument will
be the next value in ``frames``. Any additional positional
arguments can be supplied via the ``fargs`` parameter.
Expand All @@ -1390,7 +1364,6 @@ class FuncAnimation(TimedAnimation):

def func(fr: object, *fargs) -> iterable_of_artists:


frames : iterable, int, generator function, or None, optional
Source of data to pass ``func`` and each frame of the animation

Expand All @@ -1406,7 +1379,6 @@ def gen_function():
If `None`, then equivalent to passing ``itertools.count``

init_func : callable, optional

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
Expand All @@ -1426,15 +1398,15 @@ def init_func() -> iterable_of_artists:
The number of values from `frames` to cache.

interval : number, optional
Delay between frames. Defaults to 200
Delay between frames in milliseconds. Defaults to 200.

repeat_delay : number, optional
If the animation in repeated, adds a delay in milliseconds
before repeating the animation. Defaults to None
before repeating the animation. Defaults to `None`.

repeat: bool, optional
controls whether the animation should repeat when the sequence
of frames is completed.
of frames is completed. Defaults to `True`

blit : bool, optional
controls whether blitting is used to optimize drawing. Defaults
Expand Down