sdf_xarray.plotting.animate_multiple

sdf_xarray.plotting.animate_multiple#

sdf_xarray.plotting.animate_multiple(*datasets, datasets_kwargs=None, fps=10, min_percentile=0, max_percentile=100, title=None, display_sdf_name=False, move_window=False, t=None, ax=None, **common_kwargs)[source]#

Generate an animation using multiple xarray.DataArray. The intended use of this function is via sdf_xarray.dataset_accessor.EpochAccessor.animate_multiple.

Parameters:
  • datasets (DataArray) – xarray.DataArray objects containing the data to be animated

  • datasets_kwargs (list[dict[str, Any]] | None) –

    A list of dictionaries, following the same order as datasets, containing

    per-dataset matplotlib keyword arguments. The list does not need to be the same length as datasets; missing entries are initialised as empty dictionaries

  • fps (float) – Frames per second for the animation

  • min_percentile (float) – Minimum percentile of the data

  • max_percentile (float) – Maximum percentile of the data

  • title (str | None) – Custom title to add to the plot

  • display_sdf_name (bool) – Display the sdf file name in the animation title

  • move_window (bool) – Update the xlim to be only values that are not NaNs at each time interval

  • t (str | None) – Coordinate for t axis (the coordinate which will be animated over). If None, use data.dims[0]

  • ax (Axes | None) – Matplotlib axes on which to plot

  • common_kwargs – Matplotlib keyword arguments applied to all datasets. These are overridden by per-dataset entries in datasets_kwargs

Return type:

FuncAnimation

Examples

>>> anim = animate_multiple(
    ds["Derived_Number_Density_Electron"],
    ds["Derived_Number_Density_Ion"],
    datasets_kwargs=[{"label": "Electron"}, {"label": "Ion"}],
    ylim=(0e27,4e27),
    display_sdf_name=True,
    ylabel="Derived Number Density [1/m$^3$]"
)
>>> anim.save("animation.gif")