【发布时间】:2020-10-09 17:18:22
【问题描述】:
我正在创建一个 Google colab,其中包含图像上热图的一些数据可视化。我一直在使用类似于plotly website 中的代码。
网站上的链接可以正常工作,但是当尝试使用 Google Drive 链接时,它不起作用。我正在使用这种格式的链接:https://docs.google.com/uc?export=download&id=<file-id>
在 markdown 字段中使用时,图像显示良好,但不能通过 plotly 显示。
代码示例:
fig = px.density_heatmap(df, x="x", y="y",
color_continuous_scale = [(0, "rgba(0, 255, 0, 0)"),
(0.5, "rgba(0, 255, 0, 0.5)"),
(1, "rgba(0, 255, 0, 1)")],
height=810, width=1440)
fig.add_layout_image(
dict(
source="https://docs.google.com/uc?export=download&id=1JEyyYCse6sWM3yMUwDG2l7XzaGxej-VZ",
xref="x",
yref="y",
x=0,
y=0,
sizex=1920,
sizey=1080,
sizing="stretch",
opacity=1,
layer="below")
)
fig.update_layout(template="plotly_white")
fig.show()
是否有解决方案,或者只是图书馆没有考虑极端情况的情况?
编辑:我希望使用未公开的 Google Drive Link,希望可以使用 Google Colab 凭据。找到了一个可能的答案here
【问题讨论】:
标签: python plotly google-colaboratory imageurl