如何使用 Plotly-Dash 设置滑块和选择器的范围 [英] How to Range Slider and Selector with Plotly-Dash

查看:53
本文介绍了如何使用 Plotly-Dash 设置滑块和选择器的范围的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 Dash 重新创建此 Plotly 示例,但我无法获得按钮和范围滑块.有谁知道我该怎么做?

I am trying to recreate this Plotly example with Dash, but I cannot get the buttons and the range slider. Does anyone know how I can do this?

这就是我尝试过的:

traces =[{
            'x':df.index,
            'y':df.level,
            'type': 'scatter',
            'mode': 'lines',
            'name': 'a_level'
    }]
    graphs.append(dcc.Graph(
        id='a_level',
        figure={
            'data': traces,
            'layout': {
                    'type': 'date',
                    'rangeslider': {'visible':True},
                    'margin': {'b': 0, 'r': 10, 'l': 60, 't': 0}
            }
        }
    )

推荐答案

rangesliderxaxis 的一个属性.

我使用这样的东西:

app = dash.Dash(__name__, external_stylesheets=['https://codepen.io/chriddyp/pen/bWLwgP.css'])
    app.layout = html.Div([
        dcc.Graph(
            id='bar_plot',
            figure=go.Figure(
                data=area,
                layout=go.Layout(
                    xaxis={
                        'rangeslider': {'visible':True},
                        'rangeselector': {'visible':True, 'buttons':[{'step':'all'}, {'step':'day'}, {'step':'hour'}]}
                    },
                )))
    ])

这篇关于如何使用 Plotly-Dash 设置滑块和选择器的范围的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆