Get coordinates when clicking a point?
AStupidBear opened this issue · comments
AStupidBear commented
I want to display a gadfly/immerse plot on a GtkCanvas and then when I click a point I can get coordinates of that point in the plot's system. But I cannot pin down the exact function in Immerse.jl to transform event.x/y to the real x/y.
Tim Holy commented
I haven't tested, but it should be something like the test/hittest.jl
demo:
x = linspace(0,4pi,101)
y = sin(x)
figure()
p = plot(x=x,y=y,Geom.point(tag=:dots),Geom.line(tag=:line))
hfig = display(p)
hit((hfig,:dots), @guarded (figtag, i, event, dist) -> if dist < 1 println("You clicked on the point at $(x[i]), $(y[i])") end)
AStupidBear commented
But how can I use this code in my own GUI window?
Tim Holy commented
Instead of just printing the values of x[i]
and y[i]
, you could call some function that does something with them.
AStupidBear commented
I mean getting x[i]
/y[i]
on a non-immerse figure's canvas. But I realize that I can just use Immerse to do this. Thank you!