# Plot size from subplots sizes

**URL:** <https://discourse.julialang.org/t/plot-size-from-subplots-sizes/76542>\
**Category:** General Usage\
**Tags:** plotting, plots\
**Created:** [February 16, 2022, 8:38am UTC](https://discourse.julialang.org/t/plot-size-from-subplots-sizes/76542 "2022-02-16T08:38:13Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![maajdl](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/maajdl/32/22838_2.png) [@maajdl](https://discourse.julialang.org/u/maajdl)\
**Post date:** [February 16, 2022, 2:15pm UTC](https://discourse.julialang.org/t/plot-size-from-subplots-sizes/76542/3 "2022-02-16T14:15:38Z")

</div>

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:**

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

```julia
p = testplot()

```

and its output I get in Jupyterlab:  
 ![p](https://global.discourse-cdn.com/julialang/original/3X/5/d/5dcb07eb61271cff4cb270d7ef4bdf70fdcfd876.jpeg)

* * *

**This is second test:**  
(observe the distortion)

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

```

and its output:

 ![pp](https://global.discourse-cdn.com/julialang/original/3X/1/b/1b8f50e44b4680f98c96c1a26af3a98da71c2944.jpeg)

---

_[View the full topic](https://discourse.julialang.org/t/plot-size-from-subplots-sizes/76542)._
