How to catch trace visibility changed?

Dear all,

I am working on an animated scatter plot project, where I manually modify the traces visibility, setting all other traces to ‘legendonly’ when a new trace is added to all frames.

This works fine, but when I now want to change the trace visibility by clicking on the legend, only the currently displayed data frame changes, sliding through the other frames keeps the previously manually set visibility states.

Is there an event fired, when the user interacts with the legend or any other way I can catch this event, so that I can adapt the other frames accordingly?

Thank you for your help.

Best regards,

Listening to plotly_restyle should do the trick:

1 Like

Awesome, short and easy solution.
Thanks a lot @etienne!