Storing separate Makie axes from a figure

1. Storing axes separately

When making figures for publications, I often find myself wanting to store individual axes from a figure with multiple axes. This is to reduce some redundant information, such as shared axis-labels. To illustrate what I mean, consider the following MWE

using CairoMakie

fig = Figure(; size=(360,400/3), figure_padding=(0,6,2,4))
ax = [Axis(
    fig[1,i], xlabel="x", ylabel="y", aspect=1, limits=(0,1,0,1),
    xlabelsize=10, ylabelsize=10, xticklabelsize=9, yticklabelsize=9,    
    xlabelpadding=1.0, ylabelpadding=3.0,
    ylabelvisible=(i==1), yticklabelsvisible=(i==1)
) for i in 1:3]
for i in 1:3
    scatter!(ax[i], rand(10), rand(10), markersize=5)
end
colgap!(fig.layout, Relative(0.05))
resize_to_layout!(fig)
fig

In this snippet, I plot three axes, but only give the first a label on the y-axis and ticklabels are also only visible on the first axis (see fig.).

The problem arises when I want to use other frameworks (mostly TikZ) to make some indications, and/or switch around the location of these plots (e.g., when going through them 1 by one in Beamer).

To achieve this, I thought the easiest solution was to store each axis separately. That is, call something like save("axis1.pdf", ax[1]), and thereby only store that specific axis with the appropriate size, etc. However, I do not find any documentation on this kind of behavior. Is there any way to store each axis seperately, while keeping the sizes of the axes as they are in the figure?

2. A workaround that does not work: interference of labels

Something I tried was to just make three separate figures, yet in this case the fact that the first axis has y- and ytick-labels makes it very difficult to control the sizes of the figures. The reason is that Makie logically tries to fit the size of everything in the given figure size, which includes the labels (if any). So, if there are no labels, the axis itself gets more space and the figures are not of the same size. To avoid this behavior; is there a way to define the size of the axis object instead of the figure? That is, if I make a figure Figure(; size=(100,100)), can I specify an axis that has size (50,50), for example?

You can do Axis(..., width = 50, height = 50) and then to remove the whitespace resize_to_layout!(fig)

Also there was this recent thread for saving only a rectangular cropped region of a figure GLMakie saving Axis - #9 by jules