Search code examples
pythonplotlyreal-time

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?


Solution

  • You could also consider Dash...