Hi there,
Let me know how I can change a specific trace using buttons? look at the following code:
import plotly.graph_objs as go
import random as rnd
num_steps = 3
fig=go.Figure()
fig.add_scatter(y=[0, 0, 0], line={'color': 'red'},name='firsttrace')
fig.add_scatter(y=[3, 3, 3], line={'color': 'blue'},name='Secondttrace')
fig.add_scatter(y=[2, 2, 2], line={'color': 'purple'},name='Thirdtrace')
fig.add_scatter(y=[1, 1, 1], line={'color': 'gray'},name='Forthtrace')
buttons = []
for i in range(num_steps):
button = dict(method='restyle', args=[{'y': [[rnd.randint(1,3) for i in range(3)],[rnd.randint(1,3) for i in range(3)]],
'line':[{'color': 'black'},{'color': 'green'}]}], label=i)
# Add button to buttons list
buttons.append(button)
fig.layout.updatemenus = [{'buttons': buttons}]
fig.show()
in the above sample, I want to change data and color of traces with name ‘Secondttrace’ and ‘Forthtrace’ and let the other traces remain as they are. Maybe there is a way using selector, but I don’t know.
Thanks, in advanced.