I am trying to animate multiple trajectories that expand frame by frame. I managed to do so with matplotlib but now i would like to use plotly for better interactivity.
Here is the example with matplotlib and how i would like to have it look with plotly.
I was able to animate the fractions of the lines of the frame but not that they expand on the previously plottet lines like in the matplotlib example.
lines = [[([1, 2], [1, 1]),
([3, 4], [1, 3]),
([8, 7], [4, 3]),
([7, 6], [0, 1])],
[([2, 2], [1, 3]),
([4, 3], [3, 3]),
([7, 6], [3, 2]),
([6, 5], [1, 2])],
[([2, 1], [3, 3]),
([3, 2], [3, 4]),
([6, 5], [2, 1]),
([5, 6], [2, 3])],
[([1, 1], [3, 1]),
([2, 2], [4, 5]),
([5, 4], [1, 0]),
([6, 4], [3, 4])]]
traces=[]
for frame in lines:
tracesThisFrame = []
for line in frame:
tracesThisFrame.append(dict(type='scatter',
x=line[0],
y=line[1]))
traces.append(tracesThisFrame)
data = traces[0]
frames = []
t = []
for d in traces:
t = d+t
frames.append(go.Frame(data=t))
fig = go.Figure(data=data,layout=go.Layout(
xaxis=dict(range=[0, 9], autorange=False),
yaxis=dict(range=[0, 6], autorange=False),
title="Start Title",
updatemenus=[dict(
type="buttons",
buttons=[dict(label="Play",
method="animate",
args=[None])])]
), frames=frames)
pyo.plot(fig)