Hello everyone,
I am using VS Code to plot topomaps on Jupyter interactive window and encountered an issue. Minimal reproduceable codes are provided at the end to replicate the issue and images.
I found that providing subplot axes does not work. It only shows the first topomap as the image below.
However, if I type “fig” at the end, it shows all the topomaps as below.
I used plot() on random data to see if something is wrong with my environment setting, and it seems working fine as all subplots are properly done as below.
I also found that if I run the codes using terminal, there will be a total of three figures (a new one pops out after closing the old figure) for the topomap part, If I use fig.show(), it does not show the correct plot but the figure with one topomap and two empty subplots.
Does anyone know whether it is a problem of my syntax, developing environment, or the MNE library, and how to fix it?
import mne
import matplotlib.pyplot as plt
import numpy as np
mnt = mne.channels.make_standard_montage("biosemi64")
info = mne.create_info(ch_names=mnt.ch_names, sfreq=250, ch_types='eeg')
info.set_montage(mnt)
nCol = 3
fig, ax = plt.subplots(nrows=1, ncols=nCol, figsize=(20, 5))
for i in range(0, nCol):
fake_data = np.random.rand(len(mnt.ch_names))
mne.viz.plot_topomap(fake_data, info, axes=ax[i])
fig2, ax2 = plt.subplots(nrows=1, ncols=nCol, figsize=(20, 5))
for i in range(0, nCol):
fake_data = np.random.rand(len(mnt.ch_names))
ax2[i].plot(fake_data)
fig