trajan.animation.Animation.color_by#

animation.Animation.color_by(variable, cmap=None, vmin=None, vmax=None, label=None, colorbar=True)#

Color particles by a variable or a fixed matplotlib colour.

Parameters:
  • variable (str or xarray.DataArray) – A DataArray with dims (trajectory, time), a dataset variable name (e.g. 'speed'), or a fixed matplotlib colour string (e.g. 'red').

  • cmap (str or Colormap, optional) – Colormap (default: 'jet').

  • vmin, vmax (float, optional) – Colour scale limits.

  • label (str, optional) – Colorbar label.

  • colorbar (bool, optional) – Whether to draw a colorbar (default: True).

Returns:

self