# Select data points for a specific trace from a multi trace plot

**URL:** <https://community.plotly.com/t/select-data-points-for-a-specific-trace-from-a-multi-trace-plot/14379>\
**Category:** plotly.js\
**Created:** [October 9, 2018, 2:16pm UTC](https://community.plotly.com/t/select-data-points-for-a-specific-trace-from-a-multi-trace-plot/14379 "2018-10-09T14:16:41Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![koushikphy](https://avatars.discourse-cdn.com/v4/letter/k/f1d935/32.png) [@koushikphy](https://community.plotly.com/u/koushikphy)\
**Post date:** [October 9, 2018, 2:16pm UTC](https://community.plotly.com/t/select-data-points-for-a-specific-trace-from-a-multi-trace-plot/14379/1 "2018-10-09T14:16:41Z")

</div>

So I have a multitrace plot say, it has 3 traces. Now I want to select data points for a region only for 1st trace. Now the problem is when I select the region it also select datapoints from 2nd and 3rd trace, if there are data points for those traces in the selected region. But I want to select points only for 1st trace , how do I do that?

---

<div class="post-metadata">

**Author:** ![etienne](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/etienne/32/17_2.png) [@etienne](https://community.plotly.com/u/etienne)\
**Post date:** [October 9, 2018, 2:37pm UTC](https://community.plotly.com/t/select-data-points-for-a-specific-trace-from-a-multi-trace-plot/14379/2 "2018-10-09T14:37:41Z")

</div>

We don’t allow that at the moment. It would be a cool feature though.

---

<div class="post-metadata">

**Author:** ![koushikphy](https://avatars.discourse-cdn.com/v4/letter/k/f1d935/32.png) [@koushikphy](https://community.plotly.com/u/koushikphy)\
**Post date:** [October 9, 2018, 2:41pm UTC](https://community.plotly.com/t/select-data-points-for-a-specific-trace-from-a-multi-trace-plot/14379/3 "2018-10-09T14:41:38Z")

</div>

Sorry to hear that, it really could have helped me in my project. In the mean time I have to implement my own function to filter out the points for other traces.

---

<div class="post-metadata">

**Author:** ![mkrish1992](https://avatars.discourse-cdn.com/v4/letter/m/43a26b/32.png) [@mkrish1992](https://community.plotly.com/u/mkrish1992)\
**Post date:** [February 19, 2021, 5:17am UTC](https://community.plotly.com/t/select-data-points-for-a-specific-trace-from-a-multi-trace-plot/14379/4 "2021-02-19T05:17:42Z")

</div>

Its not offered natively by plotly yet, but one way of achieving this would be explicitly setting the ‘selectedpoints’ to empty array and then restyling the trace.

```auto
gd.on('plotly_selected', () => {
    // replace tn with trace number of plot from which you do not want to select points
    gd.data[tn].selectedpoints = []

    // send appropriate arguments for the restyle function below
    Plotly.restyle(arguments);
})

```

---

<div class="post-metadata">

**Author:** ![koushikphy](https://avatars.discourse-cdn.com/v4/letter/k/f1d935/32.png) [@koushikphy](https://community.plotly.com/u/koushikphy)\
**Post date:** [February 19, 2021, 7:09am UTC](https://community.plotly.com/t/select-data-points-for-a-specific-trace-from-a-multi-trace-plot/14379/5 "2021-02-19T07:09:01Z")

</div>

After I posted the question plotly had added an object `curveNumber` to the `plotly_selected` event data, from there we can easily get the trace information.
