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