Python 添加多个线图时如何更改变量名称
我已经用Plotly创建了一个双线图,当showlegend=True时,变量的名称为Trace 0和Trace 1。如何手动更改这些变量的名称 我在下面展示了代码和输出Python 添加多个线图时如何更改变量名称,python,plotly,Python,Plotly,我已经用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_wi
# 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'),
)
#将第1行/记录道添加到图2第2行
fig_linee2=go.Figure()
图2.添加轨迹(go.Scatter(
x=死亡人数(28天)[“日期”],
y=死亡人数(28天)[“新死亡28天截止日期],
记号笔(
color=“蓝色”
),
showlegend=True
))
#将测线/轨迹2添加到图2测线2
图2.添加轨迹(go.Scatter(
x=患者_adm2[“日期”],
y=患者_adm2[“新入院”],
记号笔(
color=“绿色”
),
showlegend=True)
图2.更新布局(
高度=400,
标题=口述(
“死亡人员和新冠肺炎患者”,
x=0.5,
y=0.95,
口述(
family=“Arial”,
尺寸=20,
颜色='#000000'
)
),
xaxis_title=“选定日期”,
yaxis_title='人数',
口述(
family=“Courier New,Monospace”,
尺寸=12,
颜色='#000000'),
)
将“name”参数添加到go.Scatter(x=…,y=…,name=…,…)
看