# Hide/remove annotations when a trace is hidden

**URL:** <https://community.plotly.com/t/hide-remove-annotations-when-a-trace-is-hidden/3825>\
**Category:** plotly.js\
**Created:** [April 3, 2017, 7:58pm UTC](https://community.plotly.com/t/hide-remove-annotations-when-a-trace-is-hidden/3825 "2017-04-03T19:58:02Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![viehdorf](https://avatars.discourse-cdn.com/v4/letter/v/4491bb/32.png) [@viehdorf](https://community.plotly.com/u/viehdorf)\
**Post date:** [April 3, 2017, 7:58pm UTC](https://community.plotly.com/t/hide-remove-annotations-when-a-trace-is-hidden/3825/1 "2017-04-03T19:58:02Z")

</div>

The bottom example on [https://plot.ly/javascript/text-and-annotations/#styling-and-formatting-annotations](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](https://github.com/plotly/plotly.js/issues/664)

---

<div class="post-metadata">

**Author:** ![sh.sabzevari](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/sh.sabzevari/32/9989_2.png) [@sh.sabzevari](https://community.plotly.com/u/sh.sabzevari)\
**Post date:** [May 1, 2020, 2:17am UTC](https://community.plotly.com/t/hide-remove-annotations-when-a-trace-is-hidden/3825/2 "2020-05-01T02:17:38Z")

</div>

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.
