✊🏿 Black Lives Matter. Please consider donating to Black Girls Code today.
🧬 Learn how to build RNA-Seq data apps with Python & Dash. Register for the May 20 Webinar!

Use uirevision with make_subplot

How to use the uirevision property to prevent things like zoom resetting on graph updates is described at 📣 Preserving UI State, like Zoom, in `dcc.Graph`

The function plotly.tools.make_subplots is useful for subplots.

Is there a way to make the two work together? make_subplots returns a Figure, and the post above hints that uirevision only works when return a dict of properties - is this still the case?

We don’t do a great job of documenting this, but Figure and dict are two different objects to represent the same thing: a graph. You can mutate a figure the same way you can mutate a dict, with something like:

fig = make_subplots(...)

fig['layout']['uirevision'] = 'some-constant'
1 Like

Sorry for the delay in replying - that is what we were already trying:

fig = plotly.tools.make_subplots(
    rows=3, cols=1, shared_xaxes=True, vertical_spacing=0.05, print_grid=False)
fig['layout']['uirevision'] = 'some-constant'
return fig

We get an exception: ValueError: Invalid property specified for object of type plotly.graph_objs.Layout: ‘uirevision’

I vaguely remember reading on one of the forums that this was expected (because the uirevision was a new property) but I could be wrong about that.