简体   繁体   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?

I used plotly to create an interactive timeline of my data on a Jupyter Notebook.我使用 plotly 在 Jupyter Notebook 上创建了我的数据的交互式时间线。 The plot on the notebook looks perfect and works just fine, however, when I download the notebook as an html file, I can't see the plot.笔记本电脑上的 plot 看起来很完美,工作正常,但是,当我将笔记本电脑下载为 html 文件时,我看不到 plot。

I will not share the original data frame for privacy reasons and because it isn't really relevant.出于隐私原因,我不会分享原始数据框,因为它并不真正相关。

Here's the code I used to make the graph:这是我用来制作图表的代码:

#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()

In the Jupyter notebook I get a plot that looks like this:在 Jupyter 笔记本中,我得到一个 plot,如下所示:

Plot Plot

But when I download the notebook as an html file the plot is blank, it doesn't appear.但是当我将笔记本下载为 html 文件时,plot 是空白的,它不会出现。 What should I do?我应该怎么办?

Thanks!谢谢!

A bit late, but if you want plotly figures to be downloadable from Jupyter notebook, you do:有点晚了,但是如果您希望 plotly 数字可以从 Jupyter 笔记本下载,您可以:

fig.show(renderer='notebook')

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在Jupyter笔记本中显示以前生成的图? - How do I display a previously generated plot in a Jupyter notebook? 尝试使用matplotlib内联进行绘图时,为什么在jupyter笔记本中出现NonGuiException? - Why do I get NonGuiException in jupyter notebook when trying to plot using matplotlib inline? 为什么Plotly生成的plot在我上传到Github后在Jupyter Notebook中不显示? - Why doesn't the plot generated by Plotly in a Jupyter Notebook display after I upload it on Github? Plotly - 如何从 json 文件在地图上绘制一条线? - Plotly - How do I plot a line on a map from a json file? 如何在 jupyter notebook 中逐行绘制 4000 张图像? - How can I plot 4000 images line by line in jupyter notebook? 在 Ipython notebook / Jupyter 中,Pandas 没有显示我尝试绘制的图形 - in Ipython notebook / Jupyter, Pandas is not displaying the graph I try to plot 我如何在 Jupyter 中实时绘图 - How do I plot in real time in Jupyter 我在EC2更新anaconda,然后我无法在终端打开Jupyter笔记本,我该怎么办? - I update anaconda in EC2, then I can't open Jupyter notebook in terminal, what should I do? Plotly 旭日形 plot 未在 Jupyter 笔记本中显示 - Plotly sunburst plot not showing in Jupyter notebook 当我打开 Jupyter Notebook 时,出现 Kernel 错误 - When I open Jupyter Notebook there is a Kernel Error appears
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM