heatmap#

pymovements.plotting.heatmap(gaze: Gaze, position_column: str = 'pixel', 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, add_stimulus: bool = False, path_to_image_stimulus: str | Path | None = None, stimulus_origin: str = 'upper', alpha: float = 1.0) plt.Figure[source]#

Plot a heatmap of gaze data.

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

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

  • position_column (str) – The column name of the x and y position data. (default: ‘pixel’)

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

  • cmap (colors.Colormap | str) – The colormap to use. (default: ‘jet’)

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

  • origin (str) – Set origin of y-axis, valid values are ‘lower’ or ‘upper’. (default: ‘lower’)

  • figsize (tuple[float, float]) – Figure size. (default: (15, 10))

  • cbar_label (str | None) – Label for the colorbar. (default: None)

  • show_cbar (bool) – Whether to show the colorbar. (default: True)

  • title (str | None) – Figure title. (default: None)

  • xlabel (str | None) – Set x-axis label. (default: None)

  • ylabel (str | None) – Set y-axis label. (default: None)

  • show (bool) – Whether to show the plot. (default: True)

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

  • add_stimulus (bool) – Define whether stimulus should be included. (default: False)

  • path_to_image_stimulus (str | Path | None) – Path to image stimulus. (default: None)

  • stimulus_origin (str) – Origin of stimulus. (default: ‘upper’)

  • alpha (float) – Alpha value of heatmap. (default: 1.)

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

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

Returns:

The heatmap figure.

Return type:

plt.Figure