I have build a simple app with two Tabs (using the 2nd method from here dcc.Tabs | Dash for Python Documentation | Plotly). The first Tab has a heatmap and a graph, the second tab has some buttons.
When I launch the App, the content of Tab 1 renders fine and as long as I stay in Tab 1, no problem.
When I change to Tab 2, all good there.
But when I change back to Tab 1, the graph is now differently scaled and the only way to get the correct layout back is to reload the page with the Browser’s reload button
This automatic resizing to height:450 after swapping tabs is definitely still an issue, and very annoying. It is a bug in dcc, see: Github issue
I have found that the workarounds mentioned don’t always work for every plot. I have one additional workaround to share.
Add a dcc.Tabs ‘value’ Input to the callback which generates the plot, i.e. Input('your_dcc.Tabs_id', 'value')
You don’t even have to do anything with this input. Dash will re-draw the plot every time you switch tabs, and you’ll no longer be stuck with a 450px-height Graph that screws up all your formatting. Cheers.
A couple of years later and still having the same problem here… none of the three tips worked! Does anyone have another idea? I’m using px.scatter_mapbox and the dcc.Graph is inside a