【问题标题】:using plotly in offline mode in jupyter notebook (using nbcovert --execute) opens IDE (vscode)在 jupyter notebook 中以离线模式使用 plotly(使用 nbcovert --execute)打开 IDE(vscode)
【发布时间】:2019-03-18 10:01:38
【问题描述】:

如果使用以下代码运行 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 的内容有关。

【问题讨论】:

    标签: python visual-studio-code jupyter-notebook plotly nbconvert


    【解决方案1】:

    试试这个: plotly.offline.plot(fig, filename= plots_path + key + '_plotly.html', auto_open=False)

    默认行为是它会尝试找到一个程序来立即打开 html 文件。

    【讨论】:

    • 非常感谢您的快速回复!它起作用了:) 我想知道为什么我的系统选择用 vs-code 而不是用 chrome 打开 HTML...
    • 如果需要,您可以更改与 .html 文件关联的默认应用程序,如下所示:techforluddites.com/…
    猜你喜欢
    • 2020-07-13
    • 2017-10-04
    • 2021-05-18
    • 2017-08-20
    • 2021-07-08
    • 2021-09-30
    • 1970-01-01
    • 1970-01-01
    • 2018-11-24
    相关资源
    最近更新 更多