添加变量作为 Plotly Graph 标题错误
Adding Variable as Plotly Graph Title Error
我开始学习 Python 并且我目前正在使用 Plotly 库。出于某种原因,我的标题格式导致错误
title_font = dict(
title="<b>Plot</b>",
size=14,
color='black',
family='Arial')
layout = go.Layout(title_font,
xaxis= {'title':'Temperature level'},
yaxis=dict(title='Sea Level'),
hovermode='closest')
当我将标题名称从布局中拉出并为其创建变量时出现错误。
您正在为 layout
设置 size
属性,但如错误消息所述,它不是 layout
的有效 属性。您还在 title.font
部分添加了 title
,这是不正确的。正确的代码是:
title_font = dict(
size=14,
color='black',
family='Arial')
layout = go.Layout(title="<b>Plot</b>",
title_font=title_font,
xaxis= {'title':'Temperature level'},
yaxis=dict(title='Sea Level'),
hovermode='closest')
我开始学习 Python 并且我目前正在使用 Plotly 库。出于某种原因,我的标题格式导致错误
title_font = dict(
title="<b>Plot</b>",
size=14,
color='black',
family='Arial')
layout = go.Layout(title_font,
xaxis= {'title':'Temperature level'},
yaxis=dict(title='Sea Level'),
hovermode='closest')
当我将标题名称从布局中拉出并为其创建变量时出现错误。
您正在为 layout
设置 size
属性,但如错误消息所述,它不是 layout
的有效 属性。您还在 title.font
部分添加了 title
,这是不正确的。正确的代码是:
title_font = dict(
size=14,
color='black',
family='Arial')
layout = go.Layout(title="<b>Plot</b>",
title_font=title_font,
xaxis= {'title':'Temperature level'},
yaxis=dict(title='Sea Level'),
hovermode='closest')