Hi all,
I am trying to plot a 3D animation which contains two trajectories.
For the first trajectory,
import numpy as np
import plotly.graph_objects as go
fig = go.Figure(
data=[go.Scatter3d(x=env.xsuc, y=env.ysuc, z=env.zsuc,
mode=āmarkersā,marker=dict(color=ādarkolivegreenā, size=10)),
])
fig.update_layout(
scene = dict(
xaxis=dict(range=[0.2, 3.8],title="X-axis", autorange=False),
yaxis=dict(range=[-0.334,+0.334],title="Y-axis", autorange=False),
zaxis=dict(range=[0.7, 1.1],title ="Z-axis", autorange=False),
))
frames = [go.Frame(data= [go.Scatter3d(
x=env.xsuc[:k+1],
y=env.ysuc[:k+1],
z=env.zsuc[:k+1])],
traces= [0],
name=f'frame{k}'
)for k in range(len(env.xsuc))]
fig.update(frames=frames)
fig.update_layout(updatemenus=[dict(type=ābuttonsā,
buttons=[dict(label=āPlayā,method=āanimateā,args=[None, dict(frame=dict(redraw=True,
fromcurrent=True, mode=āimmediateā)) ])])])
fig.show()
Note: env.xsuc,env,env.ysuc,env.zsuc ,env.x_par, y=env.y_par, z=env.z_par,are taken as lists in the code.
The first trajectory code executes and I have an animation in the following way(JPEG file)
I am able to obtain the animation for second trajectory as like the trajectory one as shown above.
However, I am unable to include the following second trajectory within the same animation plot
For second trajectory
fig = go.Figure(
data=[go.Scatter3d(x=env.x_par, y=env.y_par, z=env.z_par,
mode=āmarkersā,marker=dict(color=āgoldā, size=10,symbol=āsquareā)),
])
fig.update_layout(
scene = dict(
xaxis=dict(range=[0.2, 3.8],title="X-axis", autorange=False),
yaxis=dict(range=[-0.334,+0.334],title="Y-axis", autorange=False),
zaxis=dict(range=[0.7, 1.1],title ="Z-axis", autorange=False),
))
frames = [go.Frame(data= [go.Scatter3d(
x=env.x_par[:k+1],
y=env.y_par[:k+1],
z=env.z_par[:k+1])],
traces= [0],
name=f'frame{k}'
)for k in range(len(env.xsuc))]
fig.update(frames=frames)
fig.update_layout(updatemenus=[dict(type=ābuttonsā,
buttons=[dict(label=āPlayā,
method=āanimateā,
args=[None, dict(frame=dict(redraw=True,fromcurrent=True, mode=āimmediateā)) ])])])
fig.show()
I am presently trying to integrate the two trajectory codes and obtain one single animation plot for two trajectories.
Any help is highly appreciated, Thank you in advance!