I’m trying to animate a plotly 3D scatter figure and the slider is not responding (see code below). Has anybody got a clue what how to solve the issue?
Thanks and best wishes! Christian
import plotly.graph_objs as go
from plotly.subplots import make_subplots
import numpy as np
# Define the initial plot
x = MC1Array[0,:,0]
y = MC1Array[0,:,1]
z = MC1Array[0,:,2]
fig = go.Figure(data=[go.Scatter3d(x=x, y=y, z=z, mode='markers', marker=dict(size=2))])
# Add frames to the plot
frames = []
for t in range(np.shape(MC1Array[:,:,0])[0]):
x = MC1Array[t,:,0]
y = MC1Array[t,:,1]
z = MC1Array[t,:,2]
frame = go.Frame(data=[go.Scatter3d(x=x, y=y, z=z, mode='markers', name=f'{t+1}')])
frames.append(frame)
sliders=[dict(steps= [dict(method= 'animate',
args= [[ f'{k+1}'],
dict(mode= 'e',
frame= dict( duration=1000, redraw= True ),
transition=dict( duration= 0)
)
],
label=f'{k+1}'
) for k in range(np.shape(MC1Array[:,:,:])[0])],
transition= dict(duration= 30 ),
x=0,#slider starting position
y=0,
currentvalue=dict(font=dict(size=12),
prefix='Day: ',
visible=True,
xanchor= 'center'
),
len=1.0,
active=1) #slider length)
]
# Update the plot with the frames
fig.update(frames=frames)
fig.update_layout(sliders=sliders)
fig.update_scenes(xaxis_visible=False, yaxis_visible=False,zaxis_visible=False )
fig.show()