gpt4 book ai didi

python - 在 Plot.ly 条形图中显示 Logo

转载 作者:行者123 更新时间:2023-12-04 15:27:36 26 4
gpt4 key购买 nike

我目前正在做一个 dataviz 项目,我希望在我的条形图的每个条形图上方添加小图像。出于某种原因,当我上传自己的.png 文件时,它们无法显示。

当我使用 plot.ly 文档中的 .png 文件时,它工作正常。我用以下内容制作它:

new = go.Figure(data=[ 
go.Bar(name = 'DC Men',
x = dc_most_men.name,
y = dc_most_men.appearances,
marker_color ='rgb(244,188,60)'),

go.Bar(name = 'DC Females',
x = dc_most_females.name,
y = dc_most_females.appearances,
marker_color ='rgb(28,140,140)')
])

new.update_layout(
xaxis=dict(
showline=True,
showgrid=False,
showticklabels=True,
linecolor='rgb(204, 204, 204)',
linewidth=2,
ticks='outside',
tickfont=dict(
family='Arial',
size=12,
color='rgb(82, 82, 82)',
),
),
yaxis=dict(
showgrid=False,
zeroline=False,
showline=False,
showticklabels=True,
),

autosize=False,
margin=dict(
autoexpand=False,
l=100,
r=20,
t=110,
),
showlegend=False,
plot_bgcolor='white'

)
new.add_layout_image(
dict(
source='https://github.itu.dk/storage/user/2360/files/eeb40480-9c3b-11ea-99e6-b9ae4b500657',
x=0.07,
y=1,
))

new.add_layout_image(
dict(
source="https://raw.githubusercontent.com/michaelbabyn/plot_data/master/benzene.png",
x=0.17,
y=0.8,
))

new.add_layout_image(
dict(
source="https://raw.githubusercontent.com/michaelbabyn/plot_data/master/benzene.png",
x=0.275,
y=0.5,
))



new.update_layout_images(dict(
xref="paper",
yref="paper",
sizex=0.1,
sizey=0.1,
xanchor="right",
yanchor="bottom"
))

这非常好地产生了以下条形图: Image of the bar chart

但是,当我将自己的文件上传到GitHub时,似乎根本就没有显示logo。我也确保将路径更改为以下链接。

我使用的链接是:https://user-images.githubusercontent.com/47081217/82669721-3b97db00-9c3c-11ea-90f6-c525e647bc49.png

有没有我忽略的地方?

最佳答案

我不认为从github可以打开一个外部链接。您是否尝试将 png 下载到笔记本/脚本所在的同一文件夹中?

关于python - 在 Plot.ly 条形图中显示 Logo ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61955692/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com