pymovements.plotting.heatmap#

pymovements.plotting.heatmap(gaze: GazeDataFrame, position_columns: tuple[str, str] = ('x_pix', 'y_pix'), gridsize: tuple[int, int] = (10, 10), cmap: colors.Colormap | str = 'jet', interpolation: str = 'gaussian', origin: str = 'lower', figsize: tuple[float, float] = (15, 10), cbar_label: str | None = None, show_cbar: bool = True, title: str | None = None, xlabel: str | None = None, ylabel: str | None = None, show: bool = True, savepath: str | None = None) plt.Figure[source]#

Plot a heatmap of gaze data.

The heatmap displays the distribution of gaze positions across the experiment screen, for a given GazeDataFrame object. The color values indicate the time spent at each position in seconds.

Parameters:
  • gaze (GazeDataFrame) – A GazeDataFrame object.

  • position_columns (tuple[str, str], optional) – The column names of the x and y position data

  • gridsize (tuple[int, int], optional) – The number of bins in the x and y dimensions.

  • cmap (colors.Colormap | str, optional) – The colormap to use

  • interpolation (str, optional) – The interpolation method to use for plotting the heatmap. See matplotlib.pyplot.imshow for more information on available methods for interpolation. By default, ‘gaussian’ is used.

  • origin (str, optional) – origin of y-axis, valid values are ‘lower’ or ‘upper’

  • figsize (tuple[float, float], optional) – Figure size

  • cbar_label (str | None, optional) – Label for the colorbar

  • show_cbar (bool, optional) – Whether to show the colorbar.

  • title (str | None, optional) – Figure title

  • xlabel (str | None, optional) – x-axis label

  • ylabel (str | None, optional) – y-axis label

  • show (bool, optional) – Whether to show the plot

  • savepath (str | None, optional) – If provided, the figure will be saved to this path

Raises:
  • ValueError – If the position columns are not in pixels or degrees

  • ValueError – If the experiment property of the GazeDataFrame is None

Returns:

The heatmap figure.

Return type:

plt.Figure