# A list of plots as an argument for the plot-command of Plots.jl

**URL:** <https://discourse.julialang.org/t/a-list-of-plots-as-an-argument-for-the-plot-command-of-plots-jl/32433>\
**Category:** General Usage\
**Tags:** plotting\
**Created:** [December 18, 2019, 10:32am UTC](https://discourse.julialang.org/t/a-list-of-plots-as-an-argument-for-the-plot-command-of-plots-jl/32433 "2019-12-18T10:32:53Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Volker](https://avatars.discourse-cdn.com/v4/letter/v/77aa72/32.png) [@Volker](https://discourse.julialang.org/u/Volker)\
**Post date:** [December 18, 2019, 10:32am UTC](https://discourse.julialang.org/t/a-list-of-plots-as-an-argument-for-the-plot-command-of-plots-jl/32433/1 "2019-12-18T10:32:53Z")

</div>

If you consider the following code, you will get a list of plots.

```julia
using Plots
plotly()

var_names = ["var1", "var2", "var3"]

# initialize regression matrices for training, validation and test
X1 = rand(20, 3)
X2 = rand(15, 3)
X3 = rand(10, 3)

function plot_space(list_data, var_names)
    num_dim = size(list_data[1], 2)
    num_plots = num_dim*(num_dim-1)/2
    list_plots = [scatter(list_data[1][:, 1], list_data[1][:, 2], xlabel=var_names[1], ylabel=var_names[2])]
    for i in 1:num_dim        
        for j in max(3, i+1):num_dim
            if !(i==1 && j==2)
                push!(list_plots, scatter(list_data[1][:, i], list_data[1][:, j], xlabel=var_names[i], ylabel=var_names[j]))
            end
            for k in 2:length(list_data)
                scatter!(list_plots[end], list_data[k][:, i], list_data[k][:, j]);
            end
            println("($i,$j)")
        end
    end
    return list_plots
end

list_plots = plot_space([X1, X2, X3], var_names)

```

Then it would be nice to plot the plots listed in the list with ` plot(list_plots, layout = (3, 1))` or something similar? Is there already something similar?

---

<div class="post-metadata">

**Author:** ![kdyrhage](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kdyrhage/32/2326_2.png) [@kdyrhage](https://discourse.julialang.org/u/kdyrhage)\
**Post date:** [December 18, 2019, 10:37am UTC](https://discourse.julialang.org/t/a-list-of-plots-as-an-argument-for-the-plot-command-of-plots-jl/32433/2 "2019-12-18T10:37:57Z")

</div>

You can use splatting:

```julia
plot(list_plots..., layout = (3, 1))

```

---

<div class="post-metadata">

**Author:** ![Volker](https://avatars.discourse-cdn.com/v4/letter/v/77aa72/32.png) [@Volker](https://discourse.julialang.org/u/Volker)\
**Post date:** [December 18, 2019, 10:48am UTC](https://discourse.julialang.org/t/a-list-of-plots-as-an-argument-for-the-plot-command-of-plots-jl/32433/3 "2019-12-18T10:48:25Z")

</div>

Thank you very much.
