BaseFuncAnimator#
- class mpl_animators.BaseFuncAnimator(
- data,
- slider_functions,
- slider_ranges,
- fig=None,
- interval=200,
- colorbar=False,
- button_func=None,
- button_labels=None,
- start_image_func=None,
- slider_labels=None,
- **kwargs,
Bases:
objectCreate a Matplotlib backend independent data explorer which allows definition of figure update functions for each slider.
The following keyboard shortcuts are defined in the viewer:
‘left’: previous step on active slider.
‘right’: next step on active slider.
‘top’: change the active slider up one.
‘bottom’: change the active slider down one.
‘p’: play/pause active slider.
User-defined buttons can be added to the viewer by specifying the button labels and functions called when those buttons are clicked. See the descriptions of the
button_labelsandbutton_funckeyword arguments.To make this class useful the subclass must implement
_plot_start_imagewhich must define aself.imattribute which is an instance ofmatplotlib.image.AxesImage.- Parameters:
data (
iterable) – Some arbitrary data.slider_functions (
list) – A list of functions to call when that slider is changed. These functions will haveval, the axes image object and the slider widget instance passed to them, e.g.,update_slider(val, im, slider)slider_ranges (
list) – A list of[min,max]pairs to set the ranges for each slider or an array of values for all points of the slider. (The slider update function decides which to support.)fig (
matplotlib.figure.Figure, optional) –Figureto use. Defaults toNone, in which case a new figure is created.interval (
int, optional) – Animation interval in milliseconds. Defaults to 200.colorbar (
bool, optional) – Plot a colorbar. Defaults toFalse.button_labels (
list, optional) – A list of strings to label buttons. Defaults toNone. IfNoneandbutton_funcis specified, it will default to the names of the functions.button_func (
list, optional) – A list of functions to map to the buttons. These functions are called with two arguments,(animator, event)where the first argument is the animator object, and the second is amatplotlib.backend_bases.MouseEventobject. Defaults toNone.slider_labels (
list, optional) – A list of labels to draw in the slider, must be the same length asslider_functions.
- fig#
- Type:
- axes#
- Type:
Notes
Extra keywords are passed to
matplotlib.pyplot.imshow.Methods Summary
get_animation([axes, slider, startframe, ...])Return a
FuncAnimationinstance for the selected slider.label_slider(i, label)Change the slider label.
plot_start_image(ax)This method creates the initial image on the
matplotlib.axes.Axes.Methods Documentation
- get_animation(
- axes=None,
- slider=0,
- startframe=0,
- endframe=None,
- stepframe=1,
- **kwargs,
Return a
FuncAnimationinstance for the selected slider.This will allow easy saving of the animation to a file.
- Parameters:
axes (
matplotlib.axes.Axes, optional) – Thematplotlib.axes.Axesto animate. Defaults toNone, in which case the Axes associated with this animator are used. Passing a custom Axes can be useful if you want to create the animation on a custom figure that is not the figure set up by this Animator.slider (
int, optional) – The slider to animate along. Defaults to 0.startframe (
int, optional) – The frame to start the animation. Defaults to 0.endframe (
int, optional) – The frame to end the animation. Defaults toNone.stepframe (
int, optional) – The step between frames. Defaults to 1.
Notes
Extra keywords are passed to
matplotlib.animation.FuncAnimation.
- abstractmethod plot_start_image(ax)[source]#
This method creates the initial image on the
matplotlib.axes.Axes.Warning
This method needs to be implemented in subclasses.
- Parameters:
ax (
matplotlib.axes.Axes) – This is the axes on which to plot the image.- Returns:
The matplotlib object to be animated, this is usually either a
AxesImageobject, or aLine2D.- Return type: