[英]I created a plot with plotly on a Jupyter Notebook but when I download it as an html file, the plot appears blank, what should I do?
我使用 plotly 在 Jupyter Notebook 上创建了我的数据的交互式时间线。 笔记本电脑上的 plot 看起来很完美,工作正常,但是,当我将笔记本电脑下载为 html 文件时,我看不到 plot。
出于隐私原因,我不会分享原始数据框,因为它并不真正相关。
这是我用来制作图表的代码:
#Interactive Line Plot
import plotly
import plotly.graph_objects as go
#Create figure
fig = go.Figure()
fig.add_trace(
go.Scatter(x=list(df.Date), y=list(df.Transactions), marker=dict(size=20, color="blue")))
#Set title
fig.update_layout(title_text="Total Number of Transactions per Date", title_font_size=20)
#Add range slider
fig.update_layout(
xaxis=dict(
rangeselector=dict(
buttons=list([
dict(count=1,
label="1m",
step="month",
stepmode="backward"),
dict(count=6,
label="6m",
step="month",
stepmode="backward"),
dict(count=1,
label="YTD",
step="year",
stepmode="todate"),
dict(count=1,
label="1y",
step="year",
stepmode="backward"),
dict(step="all")
])
),
rangeslider=dict(
visible=True
),
type="date"
)
)
fig.show()
在 Jupyter 笔记本中,我得到一个 plot,如下所示:
但是当我将笔记本下载为 html 文件时,plot 是空白的,它不会出现。 我应该怎么办?
谢谢!
有点晚了,但是如果您希望 plotly 数字可以从 Jupyter 笔记本下载,您可以:
fig.show(renderer='notebook')
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.