Plot a plot with subplot, given plots

I don’t know how to better describe this.

Given:

p1 = plot(rand(10))
p2 = plot(rand(10))

is there a way to use p1 and p2 to produce a two-subplot figure? Something like:

p = plot(layout=(2,1))
plot!(p, p1, subplot=1)
plot!(p, p2, subplot=2)

(that does not work, but the intention is clear, I think).

https://docs.juliaplots.org/stable/layouts/

Have to install it for a real example, and you know… TTFP :wink:

Oh, yes, I know how to do plots with multiple subplots. The thing here is that I had a function that returned a plot, and now I wanted to combine multiple returns of the function into a multiple-plot plot.

(but I have managed a workaround already, by passing the Plot structure to the function and the corresponding subplot).

Anyway I was curious if that could work.

plot(p1,p2,layout=(2,1))

well, my TTFP wasn’t that bad…
image

Isn’t that what you want?

1 Like

Yes, great! didn’t realize that was possible.

1 Like