Buttons for switchable [on\off] traces

Hello,

Iā€™m making figures using python 3.5, and having trouble with buttons.
In this case I am making a histogram with barmode = ā€˜overlayā€™, with multiple traces.

I want to be able to switch each trace on or off using buttons.

Following the examples on the tutorial page, I was able to use the following format:

updatemenus = list([
dict(type=ā€œbuttonsā€,
buttons =list([
dict(
label = ā€˜Ageā€™,
method = ā€˜updateā€™,
args = [{ā€˜visibleā€™ : [True,False,False]}]),
dict(
label = ā€˜Copperā€™,
method = ā€˜updateā€™,
args = [{ā€˜visibleā€™ : [False,True,False]}]),
dict(
label = ā€˜Goldā€™,
method = ā€˜updateā€™,
args = [{ā€˜visibleā€™ : [False,False,True]}]),
dict(
label = ā€˜Allā€™,
method = ā€˜updateā€™,
args = [{ā€˜visibleā€™ : [True,True,True]}])
])
)
])

This toggles visibility for the traces, but there are many more traces I want to plot, and this gets impractical. I would like to be able to have a single button for each trace, so that each could be toggled between ā€œvisible/hiddenā€, rather than have to make a custom button with boolean [True, False, True,ā€¦] for each possible permutation.

Is this possible?

Thanks for your help.

(Edit: To be clear, I want to be able to display a custom selection from a larger group of traces by toggling them on or off with a button. If I use the method above, I have to create a button for each possible combination of on\off states, which is impractical.)

Have you noticed that you can click the legend to toggle traces? If you double click an item in the legend, it will hide all traces except for the one you double clicked. Using the legend might be easier than buttons for your use case.

Wow. I had no idea that was even a built-in feature. Thanks!

One problem I am finding with this feature of the legend is that when the legend items are part of a tracegroup (which I use for legend separation between subplots) then the entire group is toggled on/off. Have tried setting itemclick and itemdoubleclick properties of the legend but cannot undo this behaviour.

Anyone been able to keep individual legend entry toggling while grouping traces?