从命令行运行Plotly脚本

问题描述 投票:1回答:1

我正在尝试从命令行运行jupyter notebook的所有单元。对于该任务,我已完成:

jupyter nbconvert --inplace --execute myNotebook.ipynb. 

现在的问题是我的脚本包含Plotly库中的一些图,然后当我使用jupyter的界面再次打开笔记本时,图为空白。我使用了很多选项,例如:

from plotly.offline import init_notebook_mode, iplot
init_notebook_mode(connected=True)

%matplotlib inline

¿有人对这个问题有任何想法吗?

谢谢

我添加了脚本的一部分以帮助您。

import pandas as pd
import plotly
from plotly.offline import init_notebook_mode, iplot
import plotly.graph_objects as go
from datetime import datetime
init_notebook_mode(connected=True)

df = pd.DataFrame({'one' : pd.Series([10, 20, 30, 40]),'two' : pd.Series([10, 20, 30, 40])})

fig = go.Figure()
fig.add_trace(go.Scatter(x=df.one,y=df.two))
fig.update_layout(xaxis_range=[min(df.one),max(df.one)])
iplot(fig)

print(datetime.now())
python bash plot command plotly
1个回答
0
投票

您可以通过两步来解决此问题

  1. 您的笔记本不受信任存在与密谋有关的问题,请信任您的笔记本

    jupyter trust myNotebook.ipynb

  2. 现在从命令行运行笔记本电脑

    jupyter nbconvert --inplace --execute myNotebook.ipynb.

您也可以看一下related

这是我的工作笔记本图像enter image description here

enter image description here

© www.soinside.com 2019 - 2024. All rights reserved.