Black Lives Matter. Please consider donating to Black Girls Code today.

Getting the actual coordinates of a 'plotly_click'?

I have some fairly low resolution data and I need to implement a selection mechanism for the regions between those points. They are sparse enought that Plotly’s nearest-data-point selection mechanism sometimes considers no point is close enough to the mouse pointer to be the active point. In those circumstances, the coordinates from a conventional ‘click’ event and the scaling functions from my x axis tell me where the click was, in data domain, so I can easily determine which region the click occurred in. However, when the click is closer to a data point, a ‘plotly_click’ event seems to be my only option. That tells me about the currently highlighted data point, but I can see no way to distinguish which side of the data point the click occurred. In other words, Plotly wants to tell me which is the nearest fence post, but I need to know which gap between posts was clicked in. Is it possible to get at the underlying click event?

I’ve “solved” this by registering for mouse motion events, storing the reported coordinates and then using them when a plotly_click is reported.

Hi, Chris.

I’m new to plotly. I know it’s been a while since you posted that you “solved” this problem but could you share some example code for how you captured mouse motion events upon click?

Maybe this helps. Here you can find a related FR.