You can use the trick showed here: Reset Click Data when clicking on map - #3 by konsti_papa
Plotly doesn’t capture clicks outside the traces, so the trick is to add the graph into a div and use n_clicks
to reset the selection.
You might need some extra code if you want to use clickmode="event"
(to highlight the selection), since this approach won’t remove the highlight.