第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

在儀表板中,根據(jù)復(fù)選框的值繪制數(shù)據(jù)集的子集

在儀表板中,根據(jù)復(fù)選框的值繪制數(shù)據(jù)集的子集

慕容3067478 2021-06-16 15:10:16
我正在使用Dash繪制一個數(shù)據(jù)集,其中包含 x、y 列和水果類型的另一列。我在清單中添加了蘋果和葡萄。我現(xiàn)在想要做的是讓圖表顯示葡萄的 x 和 y 值,如果葡萄復(fù)選框被勾選,蘋果如果蘋果復(fù)選框被勾選,如果兩者都被勾選。有人可以幫助我嗎?這是我知道的一個非常簡單的問題。我知道我需要以某種方式更改“def ... return”部分。import dashfrom dash.dependencies import Input, Outputimport dash_core_components as dccimport dash_html_components as htmlimport pandas as pdimport plotly.graph_objs as goapp = dash.Dash()fruits = {'Day':[1,2,3,4,5,6],             'Visitors':[43,34,65,56,29,76],             'Bounce_Rate':[65,67,78,65,45,52],             'Nice_Fruits':['apple', 'apple', 'grape', 'apple', 'grape', 'grape']}df_all_fruits = pd.DataFrame(fruits)Nice_Fruits_list=df_all_fruits['Nice_Fruits'].unique()app.layout = html.Div(children=[html.H1('Payment Curve and predictor'), html.Label('fruits_1'),    dcc.Checklist(    id='fruits_checklist',    options=[{'label': i, 'value': i} for i in Nice_Fruits_list],        values=['apple', 'grape'],    labelStyle={'display': 'inline-block'}    ), dcc.Graph(        id='fruits_graph',        figure={            'data': [                go.Scatter(                    x=df_all_fruits['Visitors'],                    y=df_all_fruits['Bounce_Rate'],                    mode='markers',                    opacity=0.7,                    marker={                        'size': 15,                        'line': {'width': 0.5, 'color': 'white'}                    },                )            ],            'layout': go.Layout(                     xaxis={'type': 'linear', 'title': 'Visitors'},                yaxis={'title': 'Bounce_Rate'},                margin={'l': 40, 'b': 40, 't': 10, 'r': 10},                hovermode='closest'            )        }    ),])
查看完整描述

1 回答

?
慕絲7291255

TA貢獻1859條經(jīng)驗 獲得超6個贊

所以你想要的是更新你的數(shù)據(jù),這就是你要做的,但要這樣做,你必須把兩個圖放在同一個散點上。你確實想修改回報。您需要遍歷 Checkbox 中的值。然后告訴圖形將兩個散點放在同一個圖形上:


@app.callback(

Output('fruits_graph', 'figure'),

[Input('fruits_checklist', 'values')]

)

def update_graph(values):

      df = df_all_fruits


      return {'data': [go.Scatter(

        x= df[df['Nice_Fruits']==v]['Visitors'],

        y= df[df['Nice_Fruits']==v]['Bounce_Rate'],

    mode='markers',

        marker={

            'size': 15,

            'opacity': 0.5,

            'line': {'width': 0.5, 'color': 'white'}

        }

    ) for v in values],

    'layout': {'margin': {'l': 40, 'r': 0, 't': 20, 'b': 30}}

}

告訴我它是否解決了您的問題。


查看完整回答
反對 回復(fù) 2021-06-16
  • 1 回答
  • 0 關(guān)注
  • 170 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學習伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號