简体   繁体   中英

Plotly-Dash: How to update only figure data without changing the figure layout?

I have a 3D scatter plot, I want to update the data of the figure (when moving a slider) without changing the 3D view.

Even with this solution, the 3D view is reset:

@app.callback(Output('graph', 'figure'),
              Input('slider', 'value'),
              State('graph', 'figure'))
def update_fig(value, figure):
    if value is not None:
        data = new_data(value)
        figure['data'][0]['x'] = data['x']
        figure['data'][0]['y'] = data['y']
        figure['data'][0]['z'] = data['z']
        return figure
    else:
        return figure

Is it possible to update only the coordinates of the points?

The following should do what you want:

fig.update_layout(uirevision='constant')

If it doesn't, then please consider providing a snippet with a sample of your data and a fully runnable dash setup. I'm sure we can figure it out somehow.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM