# Splatting an array of plots

**URL:** <https://discourse.julialang.org/t/splatting-an-array-of-plots/80171>\
**Category:** New to Julia\
**Created:** [April 27, 2022, 9:03pm UTC](https://discourse.julialang.org/t/splatting-an-array-of-plots/80171 "2022-04-27T21:03:00Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![lancejnelson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lancejnelson/32/21898_2.png) [@lancejnelson](https://discourse.julialang.org/u/lancejnelson)\
**Post date:** [April 27, 2022, 9:03pm UTC](https://discourse.julialang.org/t/splatting-an-array-of-plots/80171/1 "2022-04-27T21:03:00Z")

</div>

I’m trying to construct an array of plots and then plot them all on a grid. I initialize the array like this:

`plots = Array{Plots.Plot{Plots.GRBackend}}(undef,10)`

and populate the array inside a loop like this:

`plots[i] = myplot`

Then I try to splat out the plots inside the plot command:

`plot(plots...,layout = (3,3))`

but I get an undefinedReference error. But I can do:

`plot(plots[1],plots[2],plots[3]...,layout = (3,3))`

which is not great if you have a lot of plots.

---

<div class="post-metadata">

**Author:** ![feanor12](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/feanor12/32/8212_2.png) [@feanor12](https://discourse.julialang.org/u/feanor12)\
**Post date:** [April 27, 2022, 9:05pm UTC](https://discourse.julialang.org/t/splatting-an-array-of-plots/80171/2 "2022-04-27T21:05:52Z")

</div>

I assume you generate 9 plots and save it in an array of length 10.  
Probably the undefined value in the array makes problems.

---

<div class="post-metadata">

**Author:** ![lancejnelson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lancejnelson/32/21898_2.png) [@lancejnelson](https://discourse.julialang.org/u/lancejnelson)\
**Post date:** [April 27, 2022, 9:06pm UTC](https://discourse.julialang.org/t/splatting-an-array-of-plots/80171/3 "2022-04-27T21:06:13Z")

</div>

Feeling stupid… I initialized the array to have 10 elements and then only populated the first 9.
