What is the proper way to produce a Real-Time Plot, i.e. dynamically update the plot as new data arrives?
What I have so far is this:
import time import plotly.graph_objects as go data = [1,3,2,4,3,3,2,3]
Initialize the plot:
fig = go.FigureWidget() fig.add_scatter() fig
for i in range(len(data)): time.sleep(0.3) fig.data.y = data[:i]
for i in range(len(data)): time.sleep(0.3) with fig.batch_update(): fig.data.y = data[:i]
Both produce the following dynamic plot:
- What is the difference between these 2 methods?
- Which is the advisable method?
- This works in Jupyter environments. How do I implement something like this outside of Jupyter?