How to properly set aspect for Axis defined in multiple fig positions in Makie

Hello, I have the following figure structure

fig = Figure()

ax1 = Axis(fig[1,1])
ax2 = Axis(fig[1,2])
ax3 = Axis(fig[2,1])
ax4 = Axis(fig[2,2])
ax5 = Axis(fig[1:2,3])

colsize!(fig.layout, 3, Relative(0.6))

fig

where I’m able to change the size of the third column.

However, I want now to the an equal aspect for ax5, which however takes multiple positions in the figure, so colsize!(fig.layout, 3, Aspect(1:2, 1) doesn’t work.

I would avoid to set the aspect using the aspect argument, as this doesn’t inform the figure layout to resize. Indeed, I want the axis to be exactly aligned to the figure layout.

You can nest the left group so the big axis covers just one row:

fig = Figure(size = (700, 450))

gl = GridLayout(fig[1, 1])

ax1 = Axis(gl[1,1])
ax2 = Axis(gl[1,2])
ax3 = Axis(gl[2,1])
ax4 = Axis(gl[2,2])
ax5 = Axis(fig[1, 2])

poly!(ax5, Circle(Point2f(0, 0), 5))

colsize!(fig.layout, 2, Aspect(1, 1))

fig

2 Likes

Thanks. What if I can’t nest them because my layout is more complex?

What’s the actual layout then that you’re trying to create?

Presumably by (notionally) splitting the fig into ever-so-many cells, you can create any layout you want, even without nesting?

fig = Mke.Figure()
    ax1 = Mke.Axis(fig[2:5, 2]
    ax2 = Mke.Axis(fig[2:5, 1]
    Mke.Legend(fig[6, 1]
    Mke.Label(fig[0, :]
    Mke.Label(fig[1, :]

(probably I have misunderstood what you say about the aspect!)

I have something like this

fig_simple = Figure(size=(plot_figsize_width_pt, 0.5*plot_figsize_width_pt), figure_padding=1)

Label(fig_simple[1, 1:3], "Liouvillian", tellwidth=false, tellheight=true)
Label(fig_simple[1, 4:6], "Propagator", tellwidth=false, tellheight=true)

box_λ_simple = Box(fig_simple[2:5, 1:3], cornerradius = 5, color = (λ_color, 0.25), strokecolor = :transparent)
box_ϵ_simple = Box(fig_simple[2:5, 4:7], cornerradius = 5, color = (ϵ_color, 0.25), strokecolor = :transparent)

Makie.translate!(box_λ_simple.blockscene, 0, 0, -100)
Makie.translate!(box_ϵ_simple.blockscene, 0, 0, -100)

ax_λ_simple = Axis(fig_simple[3, 2])
ax_ϵ_simple = Axis(fig_simple[3, 5])
ax_λ_gap_simple = Axis(fig_simple[4, 2])
ax_ϵ_gap_simple = Axis(fig_simple[4, 5])
ax_ϵ_symmetry_simple = Axis(fig_simple[3:4, 6])

rowsize!(fig_simple.layout, 3, Aspect(5, 1))
rowsize!(fig_simple.layout, 2, 0)
rowsize!(fig_simple.layout, 5, 0)

colsize!(fig_simple.layout, 1, 0)
colsize!(fig_simple.layout, 3, 2)
colsize!(fig_simple.layout, 4, 2)
colsize!(fig_simple.layout, 7, 0)

rowgap!(fig_simple.layout, 8)
rowgap!(fig_simple.layout, 1, 2)
rowgap!(fig_simple.layout, 3, 10)
colgap!(fig_simple.layout, 8)
colgap!(fig_simple.layout, 3, 10)
colgap!(fig_simple.layout, 5, 10)

fig_simple

You nest only the axes whose rows don’t need to be aspect constrained, so that the big square one gets its own row:

plot_figsize_width_pt = 500
λ_color = :magenta
ϵ_color = :teal
fig_simple = Figure(size=(plot_figsize_width_pt, 0.5*plot_figsize_width_pt), figure_padding=1)

Label(fig_simple[1, 1:3], "Liouvillian", tellwidth=false, tellheight=true)
Label(fig_simple[1, 4:6], "Propagator", tellwidth=false, tellheight=true)

box_λ_simple = Box(fig_simple[2:4, 1:3], cornerradius = 5, color = (λ_color, 0.25), strokecolor = :transparent)
box_ϵ_simple = Box(fig_simple[2:4, 4:7], cornerradius = 5, color = (ϵ_color, 0.25), strokecolor = :transparent)

Makie.translate!(box_λ_simple.blockscene, 0, 0, -100)
Makie.translate!(box_ϵ_simple.blockscene, 0, 0, -100)

ax_λ_simple = Axis(fig_simple[3, 2][1, 1])
ax_ϵ_simple = Axis(fig_simple[3, 5][1, 1])
ax_λ_gap_simple = Axis(fig_simple[3, 2][2, 1])
ax_ϵ_gap_simple = Axis(fig_simple[3, 5][2, 1])
ax_ϵ_symmetry_simple = Axis(fig_simple[3, 6])

colsize!(fig_simple.layout, 6, Aspect(3, 1))
rowsize!(fig_simple.layout, 2, 0)
rowsize!(fig_simple.layout, 4, 0)

colsize!(fig_simple.layout, 1, 10)
colsize!(fig_simple.layout, 3, 10)
colsize!(fig_simple.layout, 4, 10)
colsize!(fig_simple.layout, 7, 10)

rowgap!(fig_simple.layout, 8)
rowgap!(fig_simple.layout, 1, 2)
rowgap!(fig_simple.layout, 3, 10)
colgap!(fig_simple.layout, 8)
colgap!(fig_simple.layout, 3, 10)
colgap!(fig_simple.layout, 5, 10)

fig_simple

1 Like

Thank you!