xbout.plotting.animate.animate_pcolormesh

xbout.plotting.animate.animate_pcolormesh#

xbout.plotting.animate.animate_pcolormesh(data, animate_over=None, x=None, y=None, animate=True, axis_coords=None, vmin=None, vmax=None, vsymmetric=False, logscale=False, fps=10, save_as=None, ax=None, cax=None, aspect=None, extend=None, controls='both', **kwargs)[source]#

Plots a color plot which is animated with time over the specified coordinate.

Currently only supports 2D+1 data, which it plots with animatplotlib’s wrapping of matplotlib’s pcolormesh.

Parameters:
  • data (xarray.DataArray) –

  • animate_over (str, optional) – Dimension over which to animate, defaults to the time dimension

  • x (str, optional) – Dimension to use on the x axis, default is None - then use the first spatial dimension of the data

  • y (str, optional) – Dimension to use on the y axis, default is None - then use the second spatial dimension of the data

  • animate (bool, optional) – If set to false, do not create the animation, just return the block

  • axis_coords (None, str, dict) –

    Coordinates to use for axis labelling.

    • None: Use the dimension coordinate for each axis, if it exists.

    • ”index”: Use the integer index values.

    • dict: keys are dimension names, values set axis_coords for each axis separately. Values can be: None, “index”, the name of a 1d variable or coordinate (which must have the dimension given by ‘key’), or a 1d numpy array, dask array or DataArray whose length matches the length of the dimension given by ‘key’.

  • vmin (float, optional) – Minimum value to use for colorbar. Default is to use minimum value of data across whole timeseries.

  • vmax (float, optional) – Maximum value to use for colorbar. Default is to use maximum value of data across whole timeseries.

  • vsymmetric (bool, optional) – If set to true, make the color-scale symmetric

  • logscale (bool or float, optional) – If True, default to a logarithmic color scale instead of a linear one. If a non-bool type is passed it is treated as a float used to set the linear threshold of a symmetric logarithmic scale as linthresh=min(abs(vmin),abs(vmax))*logscale, defaults to 1e-5 if True is passed.

  • fps (int, optional) – Frames per second of resulting gif

  • save_as (True or str, optional) – If str is passed, save the animation as save_as+’.gif’. If True is passed, save the animation with a default name, ‘<variable name>_over_<animate_over>.gif’

  • ax (Axes, optional) – A matplotlib axes instance to plot to. If None, create a new figure and axes, and plot to that

  • cax (Axes, optional) – Matplotlib axes instance where the colorbar will be plotted. If None, the default position created by matplotlab.figure.Figure.colorbar() will be used.

  • aspect (str or None, optional) – Argument to set_aspect(), defaults to “auto”

  • extend (str or None, optional) – Passed to fig.colorbar()

  • controls (string or None, default "both") – By default, add both the timeline and play/pause toggle to the animation. If “timeline” is passed add only the timeline, if “toggle” is passed add only the play/pause toggle. If None or an empty string is passed, add neither.

  • kwargs (dict, optional) – Additional keyword arguments are passed on to the animation function animatplot.blocks.Pcolormesh

Returns:

If animate==True, returns an animatplot.Animation object, otherwise returns an animatplot.blocks.Pcolormesh instance.

Return type:

animation or block