I’m kind of confused with Dash’s behavior when filtering data.
In few words, I have a bar plot, where each bar is a country. This bar plot is connected to a dropdown that filters out countries. But, even if I filter out the country associated to the maximum, the range won’t change. A couple images might help:
You see, after filtering out United States (even if I filter it by default), Dash still “remembers” that US was the maximum. I’d like the y-axis range to be automatically updated so the maximum shown is about 1.2M, in this case. If matplotlib can do that, I’m sure this could be done here.
This is the relevant code:
html.Div(dcc.Dropdown(id='filter-tests', options=options_countries, value=['United States'], multi=True )), dcc.Graph(id='tests')
@app.callback(Output(component_id='tests', component_property='figure'), [Input(component_id='filter-tests', component_property='value')]) def plot_tests(countries): dte = data[~data.isin(countries)] fig = go.Bar(x=dte['country'], y=dte['cumulative_tests']) fig.update_yaxes(tickformat='.1%', row=3, col=1, autorange=True) return fig
My actual code is a 3x1 subplot grid, but I guess that doesn’t matter. Is there any method to make my y-axis update when changing the plotting data?