簡體   English   中英

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?

[英]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,如下所示:

Plot

但是當我將筆記本下載為 html 文件時,plot 是空白的,它不會出現。 我應該怎么辦?

謝謝!

有點晚了,但是如果您希望 plotly 數字可以從 Jupyter 筆記本下載,您可以:

fig.show(renderer='notebook')

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM