Save Time Frequency plot into a file

Hi,
@drammock would you like to give me some help ? Thank you

I am able to create TF plot. However, I have a difficulty to save this as file for publication. Could anyone give me some help ? Thanks

I am using the following code to plot

# %% Plot time significant time-frequency power

times = 1e3 * epo1.times # Change unit to ms

plt.figure(figsize=(12,5))
plt.subplots_adjust(0.12, 0.08, 0.96, 0.94, 0.2, 0.43)

plt.subplot(2, 1, 1)
# Create new stats image with only significant clusters
T_obs_plot = np.nan * np.ones_like(T_obs)
for c, p_val in zip(clusters, cluster_p_values):
    if p_val <= 0.05:
        T_obs_plot[c] = T_obs[c]
T_obs.shape
T_obs_plot.shape
times.shape
plt.imshow(T_obs,
           extent=[times[0], times[-1], freqs[0], freqs[-1]],
           aspect='auto', origin='lower', cmap='gray')

plt.imshow(T_obs_plot,
           extent=[times[0], times[-1], freqs[0], freqs[-1]],
           aspect='auto', origin='lower', cmap='RdBu_r')

plt.xlabel('Time (ms)')
plt.ylabel('Frequency (Hz)')

plt.title('Induced power - 16 channels')
plt.colorbar()

plt.show()

Also, I want to save the following figure as well with the following code. Could you also give me some help ?

mne.viz.plot_tfr_topomap(avg_tfr_averted_eye, tmin=0.800, tmax=0.850, fmin=3.0, fmax=27.0, mode='mean', show_names=True, size=10);

I think plt.savefig('someName.png') should work

yep, that will save whichever is the “currently active figure”. If you’re dealing with several figures at once, consider something like this:

fig1, ax1 = plt.subplots()
ax1.imshow(something...)

fig2, ax2 = plt.subplots()
ax2.imshow(something_else...)

fig1.savefig('filename1.pdf')
fig2.savefig('filename2.pdf')

Thanks a lot @balandongiv and @drammock