Saving image of plot from mne epochs or evoked object?

Hi all,
For some reason, if I do something like

           evoked.plot_topomap(times,  title =  evoked.comment)
           plt.savefig( subjectDirectory +'/'+ evoked.comment + '_topo.jpg')

… the file will save. But trying plt.savefig with other mne objects (eg mne.vis, evoked.plot(), or epochs.plot() ) doesn’t work.

mne.viz.plot_compare_evokeds(evokeds, picks = 'mag', title =' MEG mags')
evoked.plot(spatial_colors=True)
epochs.plot_projs_topomap()

The plot_compare_evokeds and evoked_plot has a gui option for saving the file, but I don’t see any such for the epochs plot. Either way, is there a way to save these images from python terminal?

Thank you,
Megan

MNE-Python uses various visualization packages for plotting.

evoked.plot() uses matplotlib, so plt.savefig() would work. Although, if this is part of a script, I would rather write:

fig = evoked.plot()
fig.savefig('my_figure.png')

To make it explicit which figure is being saved.

epochs.plot() uses a Qt GUI, and saving a screenshot can be done through:

fig = epochs.plot()
fig.grab().save('screenshot.png')
1 Like

Wonderful, thank you!

Megan