Why does padding around plots get increasingly large when there are more subplots?

I’m trying to make a single figure that is very long with many subplots. However, plotting behavior seems to change the larger the image gets. Specifically, the padding between the plots and the axes’ number labels seem to increase with the number of subplots. For example:

using Plots

function get_n_suplots(n::Int64)
    plt = plot(
        layout = (n, 1),
        legend = false,
        size = (500, 300*n),
        link = :x
    )
    for i in 1:n
        plot!(
            plt,
            1:10,
            1:10,
            legend = false,
            subplot = i,
        )
    end
    savefig(plt, "$(n)_subplots.png")
end

get_n_suplots(3)
get_n_suplots(15)
get_n_suplots(25)

I will show the results of these three graphs, cropping the image to the first plot for each.

3_subplots.png:

15_subplots.png:

25_subplots.png:

As you can see, the gap widens as the number of subplots increase. This occurs whether you construct the plot first and add subplot data with the subplot argument in plot! (as I did above) or you construct the subplots individually with plot and combine them as arguments in a plot call.

The margin argument seems to only have effect outside of the axes’ number labels, not between the number labels and the graph.

If you really care about padding and optimal layouts, I highly suggest switching to Makie.jl or to any other plotting ecosystem where this issue was extensively addressed: