Which conditions cause Plotly.js to reset zoom and camera state despite a stable uirevision?
0 reputation · 18 Dec 2025, 19:04 UTC
0 reputation · 18 Dec 2025, 19:04 UTC
I want Plotly.react to preserve zoom range, pan offset, and 3D camera position across data redraws by keeping layout.uirevision constant between calls.
uirevision is a primitive layout attribute; changing it forces a view reset, while a stable value should preserve view state. However, adding or removing traces can still trigger axis autorange resets even when uirevision does not change. Preservation behavior also varies across Plotly.js major versions, particularly for 3D camera state in older releases. Selection, hover state, and modebar layout edits are not covered by uirevision.
37275 reputation · 18 Dec 2025, 23:14 UTC
A stable layout.uirevision tells Plotly.react to reuse the previous view state, but it does not disable automatic axis range computation. If any axis has autorange: true (the default), adding, removing, or changing traces will recompute the range and reset zoom/pan. In 3D scenes, the camera is also reset when the trace set changes or when scene axis autorange/aspect settings are not fixed. Selection, hover, modebar edits, and double‑click resets are outside uirevision entirely.
uirevision preserves view state only when the same value and type are passed across Plotly.react calls. A missing, undefined, or differently coerced value forces a reset.xaxis.autorange: false and yaxis.autorange: false with explicit range arrays to lock ranges.scene.camera explicitly and fix scene.xaxis.autorange, scene.yaxis.autorange, scene.zaxis.autorange, plus scene.aspectmode/aspectratio.uirevision.visible on traces.x/y/z data while autorange: true.xaxis/yaxis subplot reference.type, subplot, or projection.scene.aspectmode/aspectratio.gd.fullLayout before and after two Plotly.react calls with identical uirevision; assert xaxis.range, yaxis.range, and scene.camera.eye are unchanged.autorange: true; a range change confirms autorange, not uirevision, caused the reset.autorange: false, explicit ranges, and fixed scene.camera; preservation should hold across trace data updates if uirevision is stable.uirevision + scene.camera fixes; do not ship a version‑specific workaround without this confirmation.What is the exact Plotly.js version you are using, and do your axes/scenes have autorange: true? Older releases had camera/uirevision bugs, and autorange is the most common cause of unexpected resets.
Use comments to ask for clarification. Post a solution as an answer.
37,275 reputation · 19 Dec 2025, 02:40 UTC
While a stable uirevision aims to lock the view state, the presence of structural changes to the trace array—such as adding or removing traces—can independently trigger axis autorange recalculations, even if uirevision itself remains constant.
uirevision protects view state (zoom, pan, camera).