I am trying to compute the box plot quartiles by myself to represent them on dash app. This is similar to the example shown here https://plotly.com/python/box-plots/#box-plot-with-precomputed-quartiles . The problem is this works great when tried offline, like in jupyter notebook, etc but does not work in dash.
Please help, in middle of an app and this will be an important feature!
import dash
import dash_core_components as dcc
import dash_html_components as html
from dash.dependencies import Input, Output
import plotly.graph_objects as go
external_stylesheets = ['https://codepen.io/chriddyp/pen/bWLwgP.css']
app = dash.Dash(__name__, external_stylesheets=external_stylesheets)
app.layout = html.Div([
html.Div(["Input: ",
dcc.Input(id='my-input', value='initial value', type='text')]),
dcc.Graph(id='plot')
])
@app.callback(
Output(component_id='plot', component_property='figure'),
[Input(component_id='my-input', component_property='value')]
)
def update_output_div(input_value):
fig = go.Figure()
fig.add_trace(go.Box(y=[
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9],
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9],
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
], name="Precompiled Quartiles"))
fig.update_traces(q1=[1, 2, 3], median=[4, 5, 6],
q3=[7, 8, 9], lowerfence=[-1, 0, 1],
upperfence=[5, 6, 7], mean=[2.2, 2.8, 3.2],
sd=[0.2, 0.4, 0.6], notchspan=[0.2, 0.4, 0.6])
return fig
if __name__ == '__main__':
app.run_server(debug=True)