Skip to content

uirevision property doesn't keep the viewpoint consistent #3951

Open
@lpuglia

Description

@lpuglia

The following is the copy-paste of a question I opened on stackoverflow, it looks like to be a bug, so here i go:

I'm trying to keep the viewpoint consistent in my plotly-dash web app after every callback. This should be straightforward according to many already answered questions. The following line of code should do the magic:

fig.update_layout(uirevision='constant')

Unfortunately for me, it looks like that this is not the case for 3D scatter plots, here is a very brief piece of code that should allow to reproduce my problem:

import plotly.express as px
df = px.data.iris()

import dash
from dash import dcc
from dash import html
from dash import Input, Output

app = dash.Dash()
app.layout = html.Div([
    dcc.Dropdown(['option1', 'option2', 'option3'], 'axis', id='x-dropdown', clearable=False),
    dcc.Graph(id='main-plot')
])
@app.callback(
    Output('main-plot', 'figure'),
    Input('x-dropdown', 'value'))
def update_figure(x_selector):
    fig = px.scatter_3d(df, x='sepal_length', y='sepal_width', z='petal_width',  color='species')
    fig.update_layout(uirevision='constant')
    return fig
    
app.run_server(debug=True, use_reloader=False)

This is what i'm observing:
unexpected behavior

I can tell that the uirevision is doing something since the viewpoint is not completely reset after the callback, but it is still very imprecise. Is there something I'm missing or is this the expected behavior?

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3backlogbugsomething brokensev-3annoyance with workaround

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions