如何使用设置每个下拉图的范围plot.ly公司

2024-09-28 22:23:28 发布

您现在位置:Python中文网/ 问答频道 /正文

我有一个有4个子图,我可以选择使用下拉菜单。在

我试图将这些“填充”(fill='tonexty')添加到绘图中,但是每当我添加它们时,以前自动缩放并从110开始的yaxis将重新缩放为从0开始。我希望它的范围是自动调整的,因为它是以前添加“填充”。在

检查下面的图像,查看将填充添加到图表中的“之前”和“之后”:

在此之前: enter image description here

之后: enter image description here

我曾尝试将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,这是我添加填充的地方:

^{pr2}$

Tags: falsetrue绘图titleargs布局methodlabel