Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- df = pd.read_csv('data-csv')
- columns_df = df.columns
- cols = [{'value': c, 'label': c} for c in columns_df]
- app = dash.Dash()
- app.layout = html.Div([
- html.Div([
- dcc.Dropdown(
- id='column1',
- options = cols,
- value = '')
- ], style={'width': '48%', 'display': 'inline-block'}),
- html.Div([
- dcc.Dropdown(id = 'column2',
- options = cols,
- value = '')
- ], style={'width': '48%','float': 'right', 'display': 'inline-block'}),
- html.Div([
- dcc.Graph(id='scatter_graph')
- ])
- ])
- @app.callback(
- Output('plot_graph', 'figure'),
- [Input('column1', 'value'),
- Input('column2', 'value')])
- def update_graph(value):
- data_plot = []
- trace1 = go.Scatter(x = df[value], y = df[value])
- data_plot.apppend(trace1)
- figure = {
- 'data': data_plot,
- 'layout': {
- 'title': 'Scatter Graph' }
- }
- return ([figure])
- if __name__=='__main__':
- app.run_server(debug=True)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement