x1, y1, z1 is 3D numpy array. Need to animate 3D figure in different position.
fig = go.Figure(go.Scatter3d(x=[], y=[], z=[],
mode="markers",
marker=dict(color="red", size=10)
)
,
# generating Frames
frames = [go.Frame(data= [
go.Scatter3d(x=x1[i,k,:],y=y1[i,k,:], z=z1[i,k,:])
],
traces= [0],
name=f'frame{i}{k}'
)for i in range(10) for k in range(20) # loop with k generates figure and loop with i generates position
]
)
def frame_args(duration):
return {
"frame": {"duration": duration},
"mode": "immediate",
"fromcurrent": True,
"transition": {"duration": duration, "easing": "linear"},
}
fig.update_layout(
updatemenus = [{"buttons":[
{
"args": [None, frame_args(50)],
"label": "Play",
"method": "animate",
},
{
"args": [[None], frame_args(0)],
"label": "Pause",
"method": "animate",
}],
"direction": "left",
"pad": {"r": 10, "t": 70},
"type": "buttons",
"x": 0.1,
"y": 0,
}
],
)
fig.show()
This is not giving a right figure. How it should be approached?
first loop generates this figure: need to animate below figure at different positions enter image description here