tsplot#
- pymovements.plotting.tsplot(gaze: Gaze, channels: str | list[str] | None = None, *, xlabel: str | None = None, n_cols: int | None = None, n_rows: int | None = None, rotate_ylabels: bool = True, share_y: bool = False, zero_centered_yaxis: bool = False, line_color: tuple[int, int, int] | str = 'k', line_width: int = 1, show_grid: bool = True, show_yticks: bool = True, figsize: tuple[int, int] = (15, 5), title: str | None = None, show_events: bool = False, savepath: str | None = None, ax: Axes | None = None) tuple[Figure, Axes][source]#
Plot time series with each channel getting a separate subplot.
The x-axis shows the values of the
timecolumn of the gaze samples (usually in milliseconds) if present, otherwise the sample index.- Parameters:
gaze (Gaze) – The Gaze to plot.
channels (str | list[str] | None) – Name(s) of channels to plot. List columns are unnested into one channel per component, e.g.
pixelbecomespixel_xandpixel_y. If None, all numeric columns including list columns with numeric components will be plotted. (default: None)xlabel (str | None) – Set the x label. (default: None)
n_cols (int | None) – Number of channel subplot columns. If None, it will be inferred. (default: None)
n_rows (int | None) – Number of channel subplot rows. If None, it will be inferred. (default: None)
rotate_ylabels (bool) – Set whether to rotate ylabels. (default: True)
share_y (bool) – Set if y-axes should share a common axis. (default: False)
zero_centered_yaxis (bool) – Set if y-axis should be zero-centered. (default: False)
line_color (tuple[int, int, int] | str) – Set line color. (default: ‘k’)
line_width (int) – Set line width. (default: 1)
show_grid (bool) – Set whether to show the background grid. (default: True)
show_yticks (bool) – Set whether to show yticks. (default: True)
title (str | None) – Figure title. (default: None)
show_events (bool) – Whether to plot events as shaded areas. Event spans are colored by event name and their labels are registered, so calling
fig.legend()on the returned figure shows one entry per event name. (default: False)savepath (str | None) – If given, figure will be saved to this path. (default: None)
ax (plt.Axes | None) – External axes to draw into when plotting a single channel. Ignored when
n_channels > 1. (default: None)
- Returns:
The created or provided figure and the primary axes (the first subplot).
- Return type:
tuple[plt.Figure, plt.Axes]
- Raises:
ValueError – If array has more than two dimensions.