Hello, I’m trying to update the plotted frames based on the slider. Even though the slider updates, the data on the graph doesn’t. Any ideas?
# Create figure
figure = {
'data': [{
'type': 'bar',
'x': list(srt.np.linspace(0, len(arr), num=len(arr))),
'y': arr
}],
'layout': {
'xaxis': {
'title': 'X',
'gridcolor': '#FFFFFF',
'linecolor': '#000',
'linewidth': 0,
'zeroline': False,
'autorange': True
},
'yaxis': {
'title': 'Y',
'gridcolor': '#FFFFFF',
'linecolor': '#000',
'linewidth': 0,
'autorange': True
},
'title': method,
'updatemenus': [{
'type': 'buttons',
'buttons': [{
'label': 'Play',
'method': 'animate',
'args': [None, {
'frame': {
'duration': 10,
'redraw': True
},
'fromcurrent': True,
'transition': {
'duration': 30,
'easing': 'quad-in-out'
}
}]
}]
}]
},
'frames': []
}
# Add slider
sliders = [dict(steps=[
dict(method='animate', args=[[k], dict(
mode='e', frame = dict(duration=50, redraw=False), transition=dict(duration=0)
)],
label=k) for k in range(len(frames))],
transition=dict(duration=30),
x=0,
y=0,
len=1.0,
active=0,
currentvalue=dict(font=dict(size=12),
prefix='Step: ',
visible=True,
xanchor= 'center')
)]
figure["layout"]["sliders"] = sliders
# Update frame
for k in range(len(frames)):
frame = {"data": {
'type': 'bar',
"x": list(srt.np.linspace(0, len(arr), num=len(arr))),
"y": frames[k]
}}
figure["frames"].append(frame)
fig = go.Figure(figure)