How to plot distinct plots in grid layout

Hi, I’m trying to visualize some data with Plots.jl and even with the amazing Plots documentation i am unable to plot a grid (2,2) of plots.

Specifically I would like to create something like

using Plots
plot(rand(100, 4), layout = 4)

But with my custom plots:

using Plots

x = 1:10;
y = rand(10);
plot1 = bar(x, y);
plot2 = scatter(x, y);

plot([plot1, plot2, plot1, plot2], layout = 4)

but I get a lot of errors.

I tried other methods with @layout but I am still unable to do it. What is the correct syntax please?

It seems I’ve solved this issue based on this question. I am able to plot multiple plots like this:

plots = []
for (x, y) in ...
    push!(plots, plot(x,y))
end
plot(plots...)

so the important part are the dots.

However, I tried to implement this with my example above,

using Plots

x = 1:10;
y = rand(10);
plot1 = bar(x, y);
plot2 = scatter(x, y);

plot([plot1, plot2, plot1, plot2]..., layout = 4)

and interestingly enough it shows only half of the plots! I tried to analyze further and found out that duplicate plots do not show in the final plot. See for example following snippet which shows an empty grid (no plots inside) for me:

x = 1:10;
y = rand(10);
plot1 = bar(x, y);
plot([plot1, plot1, plot1, plot1]..., layout=4)

It works well if the plot objects are distinct, using the following simpler syntax:

plot(plot1, plot2, plot3, plot4, layout = 4)

Yes, thank you. I believe I just got confused when I couldn’t see the right output because it didn’t work for my testing code of the same plots repeated multiple times.