✊🏿 Black Lives Matter. Please consider donating to Black Girls Code today.
⚡️ Concerned about the grid? Kyle Baranko teaches how to predicting peak loads using XGBoost. Register for the August webinar!

Select points in graph from dropdown menu

Hi there,

I have a plotly express scatter, with a bunch of data points. I would like to select these points in the graph by entering a value of point’s names in a dropdown menu. Is there an easy way to do that?

And in general, how do I access the pointNumber or pointIndex property from a figure object?

I would be thankful if you could give me any suggestion.

Think you should have everything you need from this page in the docs: https://dash.plotly.com/interactive-graphing

  1. The “crossfilter recipe” on this page can be modified with your dropdown(s) value as the callback input in place of Input('g1', 'selectedData'). Simplifying, update the graph figure property. Within the callback, specify which points should be selected via fig.update_traces(selectedpoints=..)

  2. The first section on that page provides examples showing the structure of points. Those will be available in the relevant figure property (Input('basic-interactions', 'selectedData'))

  "points": [
      "curveNumber": 0,
      "pointNumber": 1,
      "pointIndex": 1,
      "x": 2,
      "y": 2,
      "customdata": [

Thank you so much for your suggestion, it was helpful.

I had already tried your suggestion. The problem was that the pointNumber on the graph did not match with the index of my df. This was because I was sorting the df on a column. After restoring a proper index, it works.

Thanks again,