Hi Jon,
This indeed helps. I’m trying to extend your example to include dynamically updating an annotation as well. The annotation initializes to the start value, but does not change as the slider is changed. Can you tell me where I’m going wrong here? I added code to the args in the slider build and reference the annotations in the layout.
Thanks for any help!
Bill
import plotly
import plotly.graph_objs as go
import numpy as np
Set initial slider/title index
start_index = 10
Build all traces with visible=False
data = [go.Scatter(
visible = False,
line=dict(color=’#00CED1’, width=6),
name = '𝜈 = '+str(step),
x = np.arange(0,10,0.01),
y = np.sin(step*np.arange(0,10,0.01)))
for step in np.arange(0,5,0.1)]
Make initial trace visible
data[start_index][‘visible’] = True
Build slider steps
steps = []
for i in range(len(data)):
step = dict(
# Update method allows us to update both trace and layout properties
method = ‘update’,
args = [
# Make the ith trace visible
{‘visible’: [t == i for t in range(len(data))]},
# Set the title for the ith trace
{'title.text': 'Step %d' % i},
{'annotations.text' : 'External %d' % i}
],
)
steps.append(step)
Build sliders
sliders = [go.layout.Slider(
active = 10,
currentvalue = {“prefix”: "Frequency: "},
pad = {“t”: 50},
steps = steps
)]
layout = go.Layout(
sliders=sliders,
title={‘text’: ‘Step %d’ % start_index},
annotations=[dict(
x=0,
y=0,
text = ‘External %d’ % start_index,
)]
)
fig = go.Figure(data=data, layout=layout)
plotly.offline.plot(fig, filename=‘test.html’)