Get plot coordinates of a GLMakie mouse event

It is easy to get the position of a mouse event in pixel coordinates:

using GLMakie

fig = Figure()
ax = Axis(fig[1,1])

on(events(ax).mousebutton) do event
    if event.button == Mouse.left
        if event.action == Mouse.press || event.action == Mouse.release
            mp = events(ax).mouseposition[]
            println(mp)
        end
    end
end

fig

How does one obtain the corresponding plot coordinates?

1 Like