Save / capture interactive rotate/pan/zoom by user

Hi Dashers,
I have a 3dScatter plot in my Dash application. A very cool thing of Plotly plots is that a user can interactively rotate, pan or zoom them. However, the user adjusted camera position is lost as soon as the figure is updated by code ( the camera position goes back to the default, or what was set by the code using Figure.update_layout(…)). Is there a way to save the user adjusted camera position?

Interestingly, on the top right of the figure, there is an icon named “Reset camera to last save” which seems to imply there is a way to save the camera position in the first place. But I couldn’t find any.

I also tried to capture the user adjusted camera position in my code using full_fig.layout.scene.camera, but this dict seems to contain the default camera position or that set in code by update_layout, not the one interactively set by the user. If instead I use fig[‘layout’].scene.camera (where fig is a pointer to my Plotly graph object), I get an empty data structure.

Thanks in advance for any help

Hi,

Take a look on the layout.uirevision property. Here’s the announcement post with a simple example on how to do it.

Should be straightforward in simple cases, but do not hesitate in following up if you can’t set it right for your particular case.