I’m wondering is it able to get user mouse’s position when user click on the plot?
What I want to achieve is, when I click on the plot, I can get the correspond x and y value on this plot, so that I can then plot this point on the graph. It’s kind of like I use my mouse to draw the plot.
I’ve been looking through this page, but couldn’t find the one I want.
Appreciate for any guidance!
1 Like
How could this be done in Python?
1 Like
You should transform pointer position to cartesian point.
`var xAxis = gd._fullLayout.xaxis;
var yAxis = gd._fullLayout.yaxis;
var marginLeft = gd._fullLayout.margin.l;
var marginTop = gd._fullLayout.margin.t;
console.log(xAxis.p2c(d.event.layerX - marginLeft));
console.log(yAxis.p2c(d.event.layerY - marginTop));`
Can you read a secondary axis using gd._fullLayout ?
Yes, you can.
var xAxis2 = gd._fullLayout.xaxis2;
var yAxis2 = gd._fullLayout.yaxis2;
…
…
…