diff --git a/src/pymovements/plotting/traceplot.py b/src/pymovements/plotting/traceplot.py index fd081a4c5..7c67dc03b 100644 --- a/src/pymovements/plotting/traceplot.py +++ b/src/pymovements/plotting/traceplot.py @@ -22,6 +22,8 @@ """ from __future__ import annotations +import sys + import matplotlib import matplotlib.pyplot as plt import numpy as np @@ -30,8 +32,11 @@ from pymovements.gaze.gaze_dataframe import GazeDataFrame - -matplotlib.use('Agg') +# This is really a dirty workaround to use the Agg backend if runnning pytest. +# This is needed as Windows workers on GitHub fail randomly with other backends. +# Unfortunately the Agg module cannot show plots in jupyter notebooks. +if 'pytest' in sys.modules: # pragma: no cover + matplotlib.use('Agg') DEFAULT_SEGMENTDATA = { 'red': [ @@ -79,7 +84,7 @@ def traceplot( gaze: GazeDataFrame, x: str, y: str, - cval: np.ndarray | None = None, + cval: np.ndarray | None = None, # pragma: no cover cmap: colors.Colormap | None = None, cmap_norm: colors.Normalize | str | None = None, cmap_segmentdata: dict[str, list[list[float]]] | None = None,