taking a hint from here I wrote the following code in a notebook:
from google.colab import output
output.enable_custom_widget_manager() #make it work on google colab notebooks
import plotly.graph_objects as go
f = go.FigureWidget()
f.add_scatter(x=[1,2,4],y=[1,2,3],mode="lines")
display(f)
I then ran the following code in a new cell:
f.data[0].x = [1,2,4,6]
f.data[0].y = [1,2,3,4]
Not only does the legend mention 2 traces (even when I refresh the page and restart the kernel) after running the first cell, but I also get this:
What I expect is for the original line to be replaced by the new one, not for the new one to be added.
When looking at the figure, data for only 1 trace appears: a scatter plot with the new data from the second cell.
I don't understand what's going on and can't find an example doing what I'm trying to do.