Plot size from subplots sizes

Thanks rafael.

Below is a MWE.

The function returns a typical plot.
The first test shows this typical plot.
The second test shows the same plot twice as subplots.

As you can see the output in the second plot has been somewhat distorded.
The two-lines title now overlaps inside the plot frame.
The x-guide and y-guide texts are not totally visible.

If I look at the svg files I can see the expected size in pixels (400x300 and 800x300).
This is also a bit puzzling since I cannot see then any reason for the distortion.

I have tried changing sizes and other possible tricks, but no solution.

My aim is simply to show two such plots side-by-side shown exactly in the same way as when I plot them alone.
I have no explanation for this behaviour, this is a bit mysterious.
Could it be related to pixels and fonts? Or anything else?

Thanks for your suggestions

Michel


This is a function that returns a typical plot:

using Plots

function testplot()
    Di = 1:9
    Ei = [215, 125, 89, 69, 56, 47, 41, 36, 32]
    Oi = [216, 163, 88, 74, 61, 40, 25, 26, 22]
    markColor = [:green,:red,:green,:green,:green,:green,:red,:red,:red]
    title = "This is a test\n N=175, chi²=26  ** Poor fit"
    p = plot(xtickfontsize=8,ytickfontsize=8,xguidefontsize=8,yguidefontsize=8, titlefont=font(10))
    plot!(size=(400,300), background_color="ivory", framestyle = :box)
    plot!(title=title, xlabel="digit", ylabel="count")
    plot!(xticks=Di, ylim=(0,Inf))
    plot!(Di, Ei, ribbon=1*sqrt.(Ei), label="1σ CI", fillcolor="gray65")
    plot!(Di, Ei, ribbon=2*sqrt.(Ei), label="2σ CI", fillcolor="gray85")
    scatter!(Di, Oi, label="data", markercolor=markColor)
end

This is a first test:

p = testplot()

and its output I get in Jupyterlab:
p


This is second test:
(observe the distortion)

p = testplot()
plot(p,p, layout=grid(1,2, widths=(4/8,4/8)), size=(800,300))

and its output: