Totomobile
Totomobile

Reputation: 663

Update Plotly Fig Data after Fig.show() in Python

My goal is to run something (some optimization) in the background, and update the plot in the browser as the results are returned.

I follow the Plotly tutorial: https://plot.ly/python/creating-and-updating-figures/#the-update-traces-method

However, the last call is always fig.show(). Calling update_traces() after fig.show() in Python has no effect in the browser.

This interaction should be driven by programatically (from Python), not by the user (via a button), as in here: https://plot.ly/python/custom-buttons/#restyle-button

Is it possible to do this? Is there some call like fig.restyle() I can call in Python that would trigger a redraw on the frontend?

Upvotes: 4

Views: 3749

Answers (2)

nicolaskruchten
nicolaskruchten

Reputation: 27370

You could also consider Dash...

Upvotes: 2

nicolaskruchten
nicolaskruchten

Reputation: 27370

The way to do this would be in JupyterLab with the FigureWidget instead of a regular Figure.

Here are the relevant docs: https://plot.ly/python/figurewidget/

Upvotes: 1

Related Questions