plot_centroid_trajectory#

movement.plots.plot_centroid_trajectory(da, individual=None, keypoints=None, ax=None, **kwargs)[source]#

Plot centroid trajectory.

This function plots the trajectory of the centroid of multiple keypoints for a given individual. By default, the trajectory is colored by time (using the default colormap). Pass a different colormap through cmap if desired. If a single keypoint is passed, the trajectory will be the same as the trajectory of the keypoint.

Parameters:
  • da (xr.DataArray) – A data array containing position information, with time and space as required dimensions. Optionally, it may have individuals and/or keypoints dimensions.

  • individual (str, optional) – The name of the individual to be plotted. By default, the first individual is plotted.

  • keypoints (str, list[str], optional) – The name of the keypoint to be plotted, or a list of keypoint names (their centroid will be plotted). By default, the centroid of all keypoints is plotted.

  • ax (matplotlib.axes.Axes or None, optional) – Axes object on which to draw the trajectory. If None, a new figure and axes are created.

  • **kwargs (dict) – Additional keyword arguments passed to matplotlib.axes.Axes.scatter().

Return type:

tuple[Figure | SubFigure, Axes]

Returns:

  • fig (matplotlib.figure.Figure or matplotlib.figure.SubFigure) – If ax is provided, this is ax.figure (matplotlib.figure.Figure or matplotlib.figure.SubFigure). Otherwise, a new matplotlib.figure.Figure is created and returned.

  • ax (matplotlib.axes.Axes) – Axes on which the trajectory was drawn. If ax is provided, the input will be directly modified and returned in this value.

Examples using plot_centroid_trajectory#

Broadcast functions across multi-dimensional data

Broadcast functions across multi-dimensional data

Compute distances and angles to regions of interest

Compute distances and angles to regions of interest

Compute head direction

Compute head direction

Compute and visualise kinematics

Compute and visualise kinematics

Load and explore pose tracks

Load and explore pose tracks

Pupil tracking

Pupil tracking