# Space between subplots

**URL:** https://discourse.julialang.org/t/space-between-subplots/93897
**Category:** New to Julia
**Tags:** plots, gr
**Created:** [February 1, 2023, 11:33pm UTC](https://discourse.julialang.org/t/space-between-subplots/93897 "2023-02-01T23:33:47Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![maxee](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/maxee/32/52904_2.png) [@maxee](https://discourse.julialang.org/u/maxee)
#### Post date: [February 1, 2023, 11:33pm UTC](https://discourse.julialang.org/t/space-between-subplots/93897/1 "2023-02-01T23:33:48Z")

</div>

I can not get rid of the horizontal space between two subplots. The desired outcome is that the y-axis of the second plot is next to the far-right border of the first plot.

Using margin=0mm does make the two plots closer, but does not completely get rid of the space between the two plots, is there a different keyword argument I can use? I am unable to find more information on the layout documentation page of Plots.

Here is a minimal working example:

```julia
using Plots
gr()
plt1 = plot(rand(10))
plt2 = plot(rand(10); yformatter=_->"")
plt = plot(plt1, plt2, layout=(1,2), margin=0Plots.mm)
savefig(plt, "tmp.pdf")

```

---

<div class="post-metadata">

### Author: ![rafael.guerra](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rafael.guerra/32/216610_2.png) [@rafael.guerra](https://discourse.julialang.org/u/rafael.guerra)
#### Post date: [February 1, 2023, 11:54pm UTC](https://discourse.julialang.org/t/space-between-subplots/93897/2 "2023-02-01T23:54:38Z")

</div>

If you want to pass the margins in the last command, I would recommend using a matrix (or row-vector in this case) to cover all subplots. Note that negative margins are allowed. AFAIK, a big limitation of Plots.jl is that all this is achieved by trial and error.

```julia
using Plots, Measures; gr()
plt1 = plot(rand(10))
plt2 = plot(rand(10); yformatter=_->"")
plt = plot(plt1, plt2, layout=(1,2), left_margin=[5mm -8mm])

```
