Advertisement
Guest User

Untitled

a guest
Sep 16th, 2019
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.08 KB | None | 0 0
  1. app= dash.Dash() #create Dash app
  2. #layout for now is simple, just the graph and the dropdown with metrics.
  3. app.layout = html.Div([
  4. dcc.Graph(id='graph'),
  5. dcc.Dropdown(id='metric-dropdown',
  6. options=[{'label':'Average Maximum Temp','value':'TMAX'},
  7. {'label':'Average Minimum Temp','value':'TMIN'},
  8. {'label':'Number of days above 90','value':'t90'}])])
  9.  
  10. #callback is what actually links the input from the dropdown to some other component, here I specify
  11. #that the output will be the component with the id 'graph'
  12. @app.callback(Output('graph','figure'),
  13. [Input('metric-dropdown','value')])
  14.  
  15. #This function creates the appropriate plotly style plot from the inputted metric.
  16. def update_figure(metric):
  17. data = [go.Scatter(x=df.index, y=df[column], mode='lines', name=column)
  18. for column in [metric,f'{metric}_rolling']]
  19. layout = go.Layout(title = f'{metric} and 10 year rolling average')
  20. return {'data':data,'layout':layout}
  21.  
  22.  
  23. app.run_server()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement