Space between subplots

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:

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")

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.

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