在使用Python的MNE中,我希望在调用def完全执行后保持交互式绘图窗口打开
但是,这无法通过以下代码实现:
def get_plot():
sample_data_folder = mne.datasets.sample.data_path()
sample_data_raw_file = os.path.join(sample_data_folder, 'MEG', 'sample',
'sample_audvis_raw.fif')
raw = mne.io.read_raw_fif(sample_data_raw_file)
raw.plot()
get_plot()
这样,一旦get_plot()
完成,绘图窗口将自动关闭
另外,我在Windows10上安装了PyCharm2020.1.3
我可以知道如何处理这个问题吗
以获取PyCharm中的交互式情节。首先需要禁用
Show plots in tool window
然后,
matplotlib.use('TkAgg')
应该被允许创建一个interactive plot window
MNE
plot()
基于matplotlib
。请参阅源文件plot_raw。根据OP,matplotlib
配置块参数,可以传递给plt.show()
。这样,即使在成功调用函数后,也可以打开绘图显然,mne组也包含了这个参数
因此,只需设置
plot(block=True)
即可实现上述目标那么,完整的代码是
相关问题 更多 >
编程相关推荐