animatplot.Animation
- class animatplot.Animation(blocks, timeline=None, fig=None)[source]
The foundation of all animations.
- Parameters:
blocks (list of animatplot.animations.Block) – A list of blocks to be animated
timeline (Timeline or 1D array, optional) – If an array is passed in, it will be converted to a Timeline. If not given, a timeline will be created using the length of the first block.
fig (matplotlib figure, optional) – The figure that the animation is to occur on
- animation
a matplotlib animation returned from FuncAnimation
Methods
Updates the animation object by adding additional blocks.
Creates interactive controls for the animation
Saves an animation
Saves the animation to a gif
Creates a timeline slider.
Creates a play/pause button to start/stop the animation
- add(new)[source]
Updates the animation object by adding additional blocks.
The new blocks can be passed as a list, or as part of a second animaion. If passed as part of a new animation, the timeline of this new animation object will replace the old one.
- Parameters:
new (amp.animation.Animation, or list of amp.block.Block objects) – Either blocks to add to animation instance, or another animation instance whose blocks should be combined with this animation.
- controls(timeline_slider_args={}, toggle_args={})[source]
Creates interactive controls for the animation
Creates both a play/pause button, and a time slider at once
- Parameters:
timeline_slider_args (Dict, optional) – A dictionary of arguments to be passed to timeline_slider()
toggle_args (Dict, optional) – A dictionary of argyments to be passed to toggle()
- save(*args, **kwargs)[source]
Saves an animation
A wrapper around
matplotlib.animation.Animation.save()
- save_gif(filename)[source]
Saves the animation to a gif
A convenience function. Provided to let the user avoid dealing with writers - uses PillowWriter.
- Parameters:
filename (str) – the name of the file to be created without the file extension
- timeline_slider(text='Time', ax=None, valfmt=None, color=None)[source]
Creates a timeline slider.
- Parameters:
text (str, optional) – The text to display for the slider. Defaults to ‘Time’
ax (matplotlib.axes.Axes, optional) – The matplotlib axes to attach the slider to.
valfmt (str, optional) – a format specifier used to print the time Defaults to ‘%s’ for datetime64, timedelta64 and ‘%1.2f’ otherwise.
color – The color of the slider.