diff --git a/mne/viz/evoked.py b/mne/viz/evoked.py index 63aca378b59..b48ff42bf15 100644 --- a/mne/viz/evoked.py +++ b/mne/viz/evoked.py @@ -46,6 +46,7 @@ _set_contour_locator, plot_topomap, ) +from .ui_events import subscribe from .utils import ( DraggableColorbar, _check_cov, @@ -849,6 +850,17 @@ def _plot_lines( props=dict(alpha=0.5, facecolor="red"), ) + def on_time_change(event): + """Respond to a time change UI event.""" + for ax in np.array(axes)[selectables]: + if hasattr(ax, "_selectline") and ax._selectline is not None: + ax._selectline.remove() + + ax._selectline = ax.axvline(event.time, color="black", alpha=1) + ax.figure.canvas.draw() + + subscribe(fig, "time_change", on_time_change) + def _add_nave(ax, nave): """Add nave to axes."""