BaseFuncAnimator

class sunpy.visualization.imageanimator.BaseFuncAnimator(data, slider_functions, slider_ranges, fig=None, interval=200, colorbar=False, **kwargs)[source] [edit on github]

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 self.im attribute which is an instance of AxesImage

Parameters:
  • 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, i.e.: update_slider(val, im, slider)
  • slider_ranges (list) – 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 (mpl.figure) – Figure to use
  • interval (int) – Animation interval in ms
  • colorbar (bool) – Plot colorbar
  • button_labels (list) – List of strings to label buttons
  • button_func (list) – List of functions to map to the buttons
  • keywords are passed to imshow. (Extra) –

Methods Summary

get_animation([axes, slider, startframe, …]) Return a matplotlib.animation.FuncAnimation instance for the selected slider.
label_slider(i, label) Change the Slider label
plot_start_image(ax) This method creates the initial image on the mpl axes

Methods Documentation

get_animation(axes=None, slider=0, startframe=0, endframe=None, stepframe=1, **kwargs)[source] [edit on github]

Return a matplotlib.animation.FuncAnimation instance for the selected slider.

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

Parameters:
  • slider (int) – The slider to animate along
  • startframe (int) – The frame to start the animation
  • endframe (int) – The frame to end the animation
  • stepframe (int) – The step between frames
label_slider(i, label)[source] [edit on github]

Change the Slider label

Parameters:
  • i (int) – The index of the slider to change (0 is bottom)
  • label (str) – The label to set
plot_start_image(ax)[source] [edit on github]

This method creates the initial image on the mpl axes

Warning

This method needs to be implemented in subclasses

Parameters:ax (mpl axes) – This is the axes on which to plot the image
Returns:AxesImage – An AxesImage object, the instance returned from a plt.imshow() command.