为什么我在Github上将其绘制后在Jupyter Notebook显示器中不显示Plotly生成的图?

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

我使用Plotly在Jupyter Notebook中绘制了一个图形,并在本地正常显示。但是,在将Jupyter Notebook上传到我在Github上的存储库之一之后,代码块下方没有任何显示。是这样吗,还是我错过了什么?如何显示该图?

import plotly.graph_objs as go

data = list()
COLORS = ["aqua","sienna","coral","darkgreen","darksalmon",
          "darkslateblue","greenyellow","maroon","violet"]

for county, col in zip(COUNTIES,COLORS):
    trace = go.Scatter(x = DF.columns,
                       y = DF.loc[county,:],
                       name = county,
                       line = dict(color = col),
                       opacity = 0.8)
    data.append(trace)

fig = go.Figure(data = data,
                layout = dict(title = "County-level (Normalized) Daily New Cases"))
fig.show()
python github plot jupyter-notebook plotly
1个回答
0
投票

如果Jupyter Notebook中的图像是通过运行代码生成的,那么GitHub将不会渲染它。 GitHub在呈现文件时不执行用户代码或允许用户提供JavaScript,因为这样做存在安全风险。用户提供的代码可用于窃取凭据,攻击其他服务器或以其他方式做各种邪恶的事情。

所以答案是,这就是它的样子。

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