Skip to content

Instantly share code, notes, and snippets.

@jkrumbiegel
Created February 8, 2024 07:51
Show Gist options
  • Save jkrumbiegel/6ee194b9a07b5d67fd22fbb105b631bd to your computer and use it in GitHub Desktop.
Save jkrumbiegel/6ee194b9a07b5d67fd22fbb105b631bd to your computer and use it in GitHub Desktop.
Makie layout visualization boxes
f = Figure()
Axis(f[1, 1], title = "Hey")
Axis(f[1, 2], title = "Ho")
Colorbar(f[1, 3])
Label(f[2, :], "A long spanning label")
Colorbar(f[3, 1:2], vertical = false)
f
function show_layout(f::Figure)
fig = Figure(size = size(f.scene), backgroundcolor = :gray50)
for content in f.content
sbbox = content.layoutobservables.suggestedbbox[]
w, h = sbbox.widths
l, b = sbbox.origin
r, t = (l, b) .+ (w, h)
Box(fig, bbox = sbbox, color = :slategray2)
prot = content.layoutobservables.protrusions[]
if prot.right != 0
Box(fig, bbox = BBox(r, r+prot.right, b, t), color = :tomato)
end
if prot.left != 0
Box(fig, bbox = BBox(l-prot.left, l, b, t), color = :tomato)
end
if prot.bottom != 0
Box(fig, bbox = BBox(l, r, b-prot.bottom, b), color = :tomato)
end
if prot.top != 0
Box(fig, bbox = BBox(l, r, t, t+prot.top), color = :tomato)
end
end
fig
end
_f = show_layout(f)
@jkrumbiegel
Copy link
Author

grafik
grafik

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment