【发布时间】:2021-08-07 13:42:52
【问题描述】:
我用 Plotly 创建了一个两线图,当 showlegend=True 时,变量的名称是 Trace 0 和 Trace 1。如何手动更改这些变量的名称?
我在下面显示代码和输出。
# add line / trace 1 to fig_linee2
fig_linee2 = go.Figure()
fig_linee2.add_trace(go.Scatter(
x=Deaths_wihing_28_days2["date"],
y=Deaths_wihing_28_days2['newDeaths28DaysByDeathDate'],
marker=dict(
color="blue"
),
showlegend=True
))
# add line / trace 2 to fig_linee2
fig_linee2.add_trace(go.Scatter(
x=patients_adm2["date"],
y=patients_adm2["newAdmissions"],
marker=dict(
color="green"
),
showlegend=True))
fig_linee2.update_layout(
height=400,
title=dict(
text='<b>Death people and admitted by COVID</b>',
x=0.5,
y=0.95,
font=dict(
family="Arial",
size=20,
color='#000000'
)
),
xaxis_title="<b>Selected date</b>",
yaxis_title='<b>Number of people</b>',
font=dict(
family="Courier New, Monospace",
size=12,
color='#000000'),
)
【问题讨论】: