JuliaGraphics / Immerse.jl

Dive deeper into your data with interactive graphics

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Get coordinates when clicking a point?

AStupidBear opened this issue · comments

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.

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) 

But how can I use this code in my own GUI window?

Instead of just printing the values of x[i] and y[i], you could call some function that does something with them.

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!