How to unfold plots

Hello,
I want to unfold a vector of plots but i don’t know how to do it.

using Plots
p = [plot(a[i][1:end,2],a[i][1:end,1]) for i =1:5] 
plot(p)

It doesn’t work.
Thanks for your help

What does “unfold” mean? Can you make a minimum working example showing what isn’t working and what your desired outcome is?

Incidentally, you don’t nee to do a[i][1:end, 2], this is equivalent to just a[i][:, 2].

Do you mean you want to pass each plot in p as a separate argument to plot? This is done with the “splat” operator ..., e.g.

using Plots
p = [plot(rand(5), rand(5)) for _=1:5]
plot(p...)
2 Likes

Would you know why broadcasting does not work? I.e., plot.(p)
Actually the following works but with the different plots displaying one after the other in the same window: @. display(plot(p)). Nevermind.

Broadcasting a function over multiple arguments is not the same as calling a function with multiple arguments:

plot.(plot_array) == for p in plot_array; plot(p); end

while

plot(plot_array...) == plot(plot_array[1], plot_array[2], ..., plot_array[end])
2 Likes

plot(p…) is working !
Thanks :slight_smile:

Actually I realise I answered a very similar question on StackOverflow not too long ago:

https://stackoverflow.com/questions/68913349/how-can-i-get-multiple-histogram-plots-from-a-dataframe-in-julia/68914287#68914287