But in this case, the first figure data won’t update and the initial data remains on the figure!
It is important for me that figure data can become update after Fig.show() command. imagine I have a loop and in each loop I have new data:
import plotly.graph_objects as go
import random as rnd
fig = go.FigureWidget();
fig.add_trace(go.Bar(x=[1, 2, 3], y=[1, 3, 2]));
fig.show()
for i in range(10):
fig.update_traces(go.Bar(x=[rnd.random()*10, 1, 6], y=[2, 5, 4]));
You helped me. I found the answer by your great help:
import plotly.graph_objects as go
import random as rnd
fig = go.FigureWidget();
fig.add_trace(go.Bar(x=[1, 2, 3], y=[1, 3, 2]));
display(fig)
for i in range(10):
fig.data[0].x = [rnd.random(), 1, 6]
fig.data[0].y = [rnd.random(), 5, 4]