In Makie, when should a function accept `fig[1,1]` as input, vs an `Axis`?

Answer with lots of help from @jules on Slack

(transferred to Discourse for posterity)

You can pass fig[1,1] to make_heatmap_with_colorbar! and fig[1,1][2,1] to make_plot_below!. To continue the example:

function make_heatmap_with_colorbar!(fig)
    ax = Axis(fig[1,1])
    make_heatmap!(ax)
    make_colorbar!(fig[1,2])
    return ax
end
function outer2()
    fig = Figure()
    ax1 = make_heatmap_with_colorbar!(fig[1,1])
    ax2 = Axis(fig[1,1][2, 1])
    make_plot_below!(ax2)
    linkxaxes!(ax1, ax2)
    hidexdecorations!(ax1)
    return fig
end

This can also be written as

function mk_heatmap_with_colorbar()
    fig = Figure()
    make_heatmap_with_colorbar!(fig[1,1])
    return fig
end
function annotate!(fig)
    ax1 = content(fig[1,1][1,1])
    ax2 = Axis(fig[1,1][2,1])
    make_plot_below!(ax2)
    linkxaxes!(ax1, ax2)
    hidexdecorations!(ax1)
end
fig = mk_heatmap_with_colorbar()
annotate!(fig)

The reason I am interested is that I want to decouple mk_heatmap_with_colorbar and annotate!, and even allow them to be in two separate packages. Luckily the layouting is very versatile and can accomodate this to some extent. Though annotate! here still depends on the internal layout chosen by mk_heatmap_with_colorbar.