I’m new to plotly, so bear with me. I’m using plotly offline in Python. I’ve made a plot which shows four lines at a time. Two of those lines are fixed; the other two are based on the value chosen in a dropdown menu. I got this to work by setting
visible = [True, True] + [(True if j==i else False) for j in range(n)]*2
when specifying the visibility applied to the traces for menu option i
. Here n
is the number of options for the other two lines. This works because I’m setting the visibilities of lines (lineA, lineB, lineC1, lineC2, lineC3, lineD1, lineD2, lineD3)
, so that when option i=1
is chosen, (lineA, lineB, lineC1, lineD1)
are visible.
What I want to do next is to plot three lines at a time, but where only one is constant. So now I’m in the case where the lines are (lineA, lineB1, lineB2, lineB3, lineC1, lineC2)
, and I want to control the B
and C
lines through separate dropdown menus. How can I do this? How do I tell a dropdown menu to only apply to certain traces? (This would also simplify my first plot, which I feel was an inelegant solution.) I feel like this should have something to do with controlling the menu’s callbacks, but I haven’t had much luck in finding a tutorial on that.
(PS: I know that this can be done through a single dropdown menu by going over all possible combinations of (A,B1,C1), (A,B1,C2), ...
but the number of lines I have is 10 for B
and 7 for C
.)