我想有我的形象设置为背景,这幅画也涵盖标题和传说和轴,而不仅仅是在图像。
这在蟒蛇中是可能的吗?
就目前而言,我正在巧妙地使用绘图,但如果其他工具工作得更好,则可以使用其他工具。我可以更改fig.add_layout_image中的设置吗?
import plotly.express as px
color_dict={'Djurgården': 'dodgerblue',
'Malmö FF': 'lightcyan',
'Hammarby': 'lawngreen',
'Sirius': 'darkblue',
'AIK': 'black',
'Elfsborg': 'goldenrod',
'Norrkoping': 'lightblue',
'Mjällby': 'lightgoldenrodyellow',
'Varbergs BoIS': 'darkgreen',
'Halmstad': 'mediumblue',
'Degerfors': 'darkred',
'Kalmar': 'indianred',
'BK Häcken': 'yellow',
'Östersunds FK': 'red',
'Örebro SK': 'darkgray'
}
fig = px.scatter(df2, x=statx, y=staty, color="Team",
size="MP", color_discrete_map=color_dict)
fig.add_annotation(text="Magnus Eriksson",
xref="paper", yref="paper",
x=0.16, y=1, showarrow=False, bgcolor="black", font=dict(
color="white"
))
fig.add_annotation(text="Mohanad Jeahze",
xref="paper", yref="paper",
x=0.225, y=0.9, showarrow=False, bgcolor="black", font=dict(
color="white"
))
fig.add_annotation(text="Darijan Bojanic",
xref="paper", yref="paper",
x=0.48, y=0.8, showarrow=False, bgcolor="black", font=dict(
color="white"
))
fig.add_annotation(text="Moustafa Zeidan",
xref="paper", yref="paper",
x=0.55, y=0.6, showarrow=False, bgcolor="black", font=dict(
color="white"
))
fig.add_annotation(text="Akinkunmi Amoo",
xref="paper", yref="paper",
x=0.8, y=0.55, showarrow=False, bgcolor="black", font=dict(
color="white"
))
fig.add_annotation(text="Tashreeq Matthews",
xref="paper", yref="paper",
x=0.8, y=0.475, showarrow=False, bgcolor="black", font=dict(
color="white"
))
fig.add_annotation(text="Edward Chilufya",
xref="paper", yref="paper",
x=0.82, y=0.375, showarrow=False, bgcolor="black", font=dict(
color="white"
))
fig.add_annotation(text="Patrick Wålemark",
xref="paper", yref="paper",
x=0.975, y=0.32, showarrow=False, bgcolor="black", font=dict(
color="white"))
fig.update_layout(
#title="Allsvenskan 2021: xT Passing vs xT Dribble",
title={
'text': "Allsvenskan 2021: xT Passing vs xT Dribble",
'y':0.95,
'x':0.5,
'xanchor': 'center',
'yanchor': 'top'},
xaxis_title="Normalized Value: xT Dribbles per 90",
yaxis_title="Normalized Value: xT Passes per 90",
legend_title="Teams Allsvenskan 2021",
)
img_width = 1
img_height = 1
scale_factor = 2.5
fig.add_layout_image(
dict(
sizex=img_width * scale_factor,
y=img_height * scale_factor,
sizey=img_height * scale_factor,
xref="x",
yref="y",
opacity=1.0,
layer="below",
sizing="stretch",
source="LJUS_BG_Playmaker.png")
)
fig.show()
´´´
发布于 2022-03-28 08:46:35
尝尝这个。
backgroundImage = PhotoImage("D:\Documents\example.png")
https://stackoverflow.com/questions/71644599
复制相似问题