I'm trying to implement two sliders in one fig of plotly I tried the following
# Create figure
fig = go.Figure()
# Add traces, one for each slider step
for step in np.arange(1, 5, 1):
fig.add_trace(
go.Scatter(
visible=False,
line=dict(color="#00CED1", width=6),
name=" = " + str(step),
x=np.arange(0, 10, 0.01),
y=[step]*50))
# Make 10th trace visible
fig.data[1].visible = True
# Create and add slider
sliders = []
for j in range(int(len(fig.data)/2)):
steps=[]
for i in range(int(len(fig.data)/2)):
step = dict(
method="update",
args=[{"visible": [False] * (int(len(fig.data)/2))},
{"title": "Slider switched to step: " + str(i)}], # layout attribute
)
step["args"][0]["visible"][i] = True # Toggle i'th trace to "visible"
steps.append(step)
sliders.append(dict(active=0, currentvalue={"prefix": "slider: "}, pad={"t": (80 * j + 20)}, steps=steps))
fig.update_layout(sliders=sliders)
plotly.offline.plot(fig, filename=f'test.html')
The two sliders not working together, in this example, each slider has two options. But if the first one is in one position, moving the second one doesn't seem to know what the first one status is. Any suggestions?