Hide/remove annotations when a trace is hidden

The bottom example on https://plot.ly/javascript/text-and-annotations/#styling-and-formatting-annotations shows how to click to plot an annotation at a given point. I use this a bunch on my current plot, which has a large number of traces that are selectively toggled on/off by users.

Is there a way that I can optionally cause turning off/hiding a trace to also hide or remove the clicked annotations for that specific trace?

Edit: Just found this issue on Github, https://github.com/plotly/plotly.js/issues/664

3 Likes

Just wondering if this is solved! I have the same issue. I want to connect the annotations to trace, something like using the legendgroup, to hide them together. I am using python. I tried the legendgroup which hits error on annotations.