我有一个包含4个子图的图表,我可以使用下拉菜单选择。
我试图添加这些"馅料" (fill='tonexty'
)进入图表,但每当我添加它们时,之前自动调整并在110处启动的yaxis将重新调整为从0开始。我希望其范围可以像添加之前一样自动调整范围"填充"。
检查下面的图片以查看"之前" """"将填充添加到图表中:
我已尝试将autorange=True
添加到图表的布局中,但它无效。
您可以在下面查看我的布局。
layout = go.Layout(
title="Cotação do Café em Dólares Americanos (U$)",
xaxis=dict(
title="Período",
titlefont=dict(
family='Courier New, monospace',
size=18,
color='#7f7f7f'
)
),
yaxis=dict(
title="Valor U$",
autorange=True,
titlefont=dict(
family='Courier New, monospace',
size=18,
color='#7f7f7f'
)
),
updatemenus=list([
dict(
buttons=list([
dict(
args=['visible', [True, False, False, False]],
label='Variação Anual',
method='restyle'
),
dict(
args=['visible', [False, True, False, False]],
label='Variação Semestral',
method='restyle'
),
dict(
args=['visible', [False, False, True, False]],
label='Variação Mensal',
method='restyle'
),
dict(
args=['visible', [False, False, False, True]],
label='Variação Semanal',
method='restyle'
)
]),
)
]),
)
这是图的Scatter
,这是我添加填充的地方:
trace_max = go.Scatter(
y = lista_precos_max,
x = lista_datas_max,
fill='tonexty',
line=go.Line(color='blue')
)
trace_semestre = go.Scatter(
y = lista_precos_semestre,
x = lista_datas_semestre,
visible = False,
fill='tonexty',
line=go.Line(color='orange')
)
trace_mes = go.Scatter(
y = lista_precos_mes,
x = lista_datas_mes,
fill='tonexty',
visible = False,
)
trace_semana = go.Scatter(
y = lista_precos_semana,
x = lista_datas_semana,
fill='tonexty',
visible = False,
)