如果运行一个jupyter笔记本(使用nbconvert --execute)并使用以下代码,我有点困惑,为什么会发生这种情况:
for key in dict:
data = [go.Bar (x = dict[key].values(),
y = dict[key].keys(),
orientation = 'h')]
layout = go.Layout(title = key, showlegend = False)
fig = go.Figure(data = data, layout = layout)
plotly.offline.plot(fig, filename= plots_path + key + '_plotly.html')
总是导致启动vs-code。有没有人以前遇到过这个问题?我怎么能抑制它,因为我在循环中进行绘图,每次运行后关闭10个以上的vs-code窗口非常烦人。
显然,如果我评论最后一行没有vs-code窗口弹出,它必须对写入html做一些事情。
试试这个:plotly.offline.plot(fig, filename= plots_path + key + '_plotly.html', auto_open=False)
默认行为是它会尝试找到一个程序来立即打开html文件。