LineAnimator

class sunpy.visualization.imageanimator.LineAnimator(data, plot_axis_index=-1, axis_ranges=None, ylabel=None, xlabel=None, xlim=None, ylim=None, **kwargs)[source] [edit on github]

Bases: sunpy.visualization.imageanimator.ArrayAnimator

Create a matplotlib backend independent data explorer for 1D plots.

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.

Parameters:
  • data (ndarray) – The y-axis data to be visualized
  • plot_axis_index (int) – The axis used to plot against xdata. Default = -1, i.e. last dimension of arrary.
  • fig (matplotlib.figure) – Figure to use
  • axis_ranges (list of physical coordinates or None) – Each element of axis_ranges provides an array of physical coordinates for the corresponding dimension of the data array. If an element is None, array indices will be used for that axis. If axis_range itself is None, array indices will be used for all axes. For more information, see the Notes section of this docstring.
  • xlabel (str) – Label of x-axis of plot.
  • ylabel (str) – Label of y-axis of plot.
  • xlim (tuple) – Limits of x-axis of plot.
  • ylim (tuple) – Limits of y-axis of plot.
  • interval (int) – Animation interval in ms
  • button_labels (list) – List of strings to label buttons
  • button_func (list) – List of functions to map to the buttons
  • keywords are passed to plot. (Extra) –

Notes

Additional information on API of axes_ranges kwarg.

  1. X-axis values must be supplied (if desired) as an array in the element of the axis_ranges list corresponding to the plot_axis_index in the data array, i.e. x_axis_values == axis_ranges[plot_axis_index]
  2. The shape of the x-axis values array can take two forms.
    1. First, it can equal the the length of the data array along the dimension corresponding to the x-axis, i.e. len(axis_ranges[plot_axis_index]) == len(data[plot_axis_index]) In this scenario the same x-axis values are used in every frame of the animation.
    2. Second, the x-axis array can have the same shape as the data array. In this scenario the x-axis is refreshed for each frame. For example, if data.shape == axis_ranges[plot_axis_index] == (4, 3), where plot_axis_index == 0, the 0th frame of the animation will show data from data[:, 0] with the x-axis described by axis_ranges[plot_axis_index][:, 0], while the 1st frame will show data from data[:, 1] with the x-axis described by axis_ranges[plot_axis_index][:, 1].
  3. For the slider axes the axis range is an array of the same length as the dimension of the data array to which that slider corresponds.

Methods Summary

plot_start_image(ax) Sets up plot of initial image.
update_plot(val, line, slider) Updates plot based on slider/array dimension being iterated.

Methods Documentation

plot_start_image(ax)[source] [edit on github]

Sets up plot of initial image.

update_plot(val, line, slider)[source] [edit on github]

Updates plot based on slider/array dimension being iterated.