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

**URL:** https://discourse.julialang.org/t/why-does-padding-around-plots-get-increasingly-large-when-there-are-more-subplots/130503
**Category:** General Usage
**Tags:** question, plotting
**Created:** [July 5, 2025, 9:31pm UTC](https://discourse.julialang.org/t/why-does-padding-around-plots-get-increasingly-large-when-there-are-more-subplots/130503 "2025-07-05T21:31:59Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![miles-1](https://avatars.discourse-cdn.com/v4/letter/m/54ee81/32.png) [@miles-1](https://discourse.julialang.org/u/miles-1)
#### Post date: [July 5, 2025, 9:31pm UTC](https://discourse.julialang.org/t/why-does-padding-around-plots-get-increasingly-large-when-there-are-more-subplots/130503/1 "2025-07-05T21:31:59Z")

</div>

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:

```julia
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`:

 ![3_subplots](https://global.discourse-cdn.com/julialang/original/3X/4/0/403812d0fa0f8c7e76eded16393633ee04543c47.png)

`15_subplots.png`:

 ![15_subplots](https://global.discourse-cdn.com/julialang/original/3X/5/a/5a1432b668b0c91a07c3b5c0c26492444dbb4c1a.png)

`25_subplots.png`:

 ![25_subplots](https://global.discourse-cdn.com/julialang/original/3X/f/c/fced62eed8e1280880c9c02b41e68f342286a9a6.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.

---

<div class="post-metadata">

### Author: ![juliohm](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/juliohm/32/215266_2.png) [@juliohm](https://discourse.julialang.org/u/juliohm)
#### Post date: [July 5, 2025, 11:40pm UTC](https://discourse.julialang.org/t/why-does-padding-around-plots-get-increasingly-large-when-there-are-more-subplots/130503/2 "2025-07-05T23:40:53Z")

</div>

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:

[![](https://global.discourse-cdn.com/julialang/original/3X/d/8/d8a888a8a754abde22d12364e6b746472f4d2390.jpeg "A deep dive into MakieLayout | Julius Krumbiegel | JuliaCon 2021") ](https://www.youtube.com/watch?v=AtqXFfaMZqo)
