how to save the result of plot_topomap() in a image file

hello,
in my project i need to save the the topomap plot of all our records with the hero but i cant save the figure can any help me ?

What do you mean by “I can’t save the figure”?

MNE plotting function return a matplotlib figure. You can save it with fig.savefig.
c.f. matplotlib.pyplot.savefig — Matplotlib 3.7.1 documentation

Mathieu

i tried this but the saved file contains nothing
plot_topomap(max_score, raw.info, cmap=cm.viridis,cnorm=(colors.Normalize(vmin=vmin, vmax=vmax)), contours=0, size=3)

plt.savefig(“test.png”)

Hello,

Looks like you are using mne.viz.plot_topomap which returns an AxesImage and a ContourSet (doc here: mne.viz.plot_topomap — MNE 1.5.0.dev13+g52fde5b8e documentation).
Thus:

im, _ = plot_topomap(...)
im.imsave(fname)

Mathieu

1 Like