class sunpy.visualization.animator.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)[source]

Bases: object

Create 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.

This viewer can have user defined buttons added by specifying the labels and functions called when those buttons are clicked as keyword arguments.

To make this class useful the subclass must implement _plot_start_image which must define a attribute which is an instance of matplotlib.image.AxesImage.

  • data (iterable) – Some arbitrary data.

  • slider_functions (list) – A list of functions to call when that slider is changed. These functions will have val, 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) – Figure to use. Defaults to None.

  • interval (int, optional) – Animation interval in milliseconds. Defaults to 200.

  • colorbar (bool, optional) – Plot a colorbar. Defaults to False.

  • button_labels (list, optional) – A list of strings to label buttons. Defaults to None. If None and button_func is 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 a matplotlib.backend_bases.MouseEvent object. Defaults to None.

  • slider_labels (list, optional) – A list of labels to draw in the slider, must be the same length as slider_functions.


Extra keywords are passed to matplotlib.pyplot.imshow.

Methods Summary

get_animation([axes, slider, startframe, …])

Return a FuncAnimation instance for the selected slider.

label_slider(i, label)

Change the slider label.


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)[source]

Return a FuncAnimation instance for the selected slider.

This will allow easy saving of the animation to a file.

  • axes (matplotlib.axes.Axes, optional) – The matplotlib.axes.Axes to animate. Defaults to None.

  • 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 to None.

  • stepframe (int, optional) – The step between frames. Defaults to 1.


Extra keywords are passed to matplotlib.animation.FuncAnimation.

label_slider(i, label)[source]

Change the slider label.

  • i (int) – The index of the slider to change (0 is bottom).

  • label (str) – The label to set.


This method creates the initial image on the matplotlib.axes.Axes.


This method needs to be implemented in subclasses.


ax (matplotlib.axes.Axes) – This is the axes on which to plot the image.


matplotlib.artist.Artist – The matplotlib object to be animated, this is usually either a AxesImage object, or a Line2D.