Not necessarily “simple” but you can project the point you want whenever the axis scene projection or position in the scene changes:
let
x = -3:0.05:3
y = exp.(-x .^ 2)
fig = Figure(resolution = (600, 400))
ax1 = Axis(fig[1, 1])
lines!(ax1, x, y)
scatter!(ax1,[1.2],[0.6],label = "I want the inset centered at (x,y) = (1.2,0.6)")
axislegend()
bbox = lift(ax1.scene.camera.projectionview, ax1.scene.px_area) do _, pxa
p = Makie.project(ax1.scene, Point(1.2, 0.6))
c = p + pxa.origin
Rect2f(c .- Point2f(50, 50), (100, 100))
end
# inset
ax2 = Axis(fig, bbox = bbox, title = "inset centered on point", backgroundcolor = (:white, 0.9))
translate!(ax2.blockscene, 0, 0, 100)
lines!(ax2, x, y, color = :red)
fig
end
If you translate the axis blockscene forward it correctly covers the other content.
Another option could be to specify a rectangle in data coordinates:
let
x = -3:0.05:3
y = exp.(-x .^ 2)
fig = Figure(resolution = (600, 400))
ax1 = Axis(fig[1, 1])
lines!(ax1, x, y)
scatter!(ax1,[1.2],[0.6],label = "I want the inset centered at (x,y) = (1.2,0.6)")
axislegend()
bbox = lift(ax1.scene.camera.projectionview, ax1.scene.px_area) do _, pxa
bl = Makie.project(ax1.scene, Point2f(0, 0)) + pxa.origin
tr = Makie.project(ax1.scene, Point2f(2, 0.5)) + pxa.origin
Rect2f(bl, tr - bl)
end
# inset
ax2 = Axis(fig, bbox = bbox, title = "inset on rect in data coords")
translate!(ax2.blockscene, 0, 0, 100)
lines!(ax2, x, y, color = :red)
fig
end