Add vertical lines to mne.viz.plot_raw(raw)

Hello!

I have following line of code
fig = mne.viz.plot_raw(raw_selection, start=start, duration=duration, show=False,
show_scrollbars=False, show_scalebars=False, n_channels=len(ch_names))

It plots roughly 25 channels worth of raw data. What I would like to do, is add vertical lines to this figure in the spot where there are integer valued seconds, such as [73, 74 75] etc. How to do this? I have tried adding grids, using ax.axvline functions etc. but I can’t get any lines to show.

  • MNE-Python version: 0.23

you can access the main plot axes object like this: fig.mne.ax_main. So something like

fig = raw.plot()
fig.mne.ax_main.axvline(74, color='green', linestyle='--')

should work.

1 Like

Hi,

Thanks for your quick response @drammock. This worked!