# How to unfold plots

**URL:** https://discourse.julialang.org/t/how-to-unfold-plots/71196
**Category:** General Usage
**Tags:** question, plotting
**Created:** [November 9, 2021, 9:38am UTC](https://discourse.julialang.org/t/how-to-unfold-plots/71196 "2021-11-09T09:38:07Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![corny85](https://avatars.discourse-cdn.com/v4/letter/c/a88e4f/32.png) [@corny85](https://discourse.julialang.org/u/corny85)
#### Post date: [November 9, 2021, 9:38am UTC](https://discourse.julialang.org/t/how-to-unfold-plots/71196/1 "2021-11-09T09:38:07Z")

</div>

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

```julia
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

---

<div class="post-metadata">

### Author: ![nilshg](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nilshg/32/2283_2.png) [@nilshg](https://discourse.julialang.org/u/nilshg)
#### Post date: [November 9, 2021, 12:10pm UTC](https://discourse.julialang.org/t/how-to-unfold-plots/71196/2 "2021-11-09T12:10:37Z")

</div>

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]`.

---

<div class="post-metadata">

### Author: ![yha](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/yha/32/3502_2.png) [@yha](https://discourse.julialang.org/u/yha)
#### Post date: [November 9, 2021, 12:19pm UTC](https://discourse.julialang.org/t/how-to-unfold-plots/71196/3 "2021-11-09T12:19:30Z")

</div>

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.

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

```

---

<div class="post-metadata">

### Author: ![rafael.guerra](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rafael.guerra/32/216610_2.png) [@rafael.guerra](https://discourse.julialang.org/u/rafael.guerra)
#### Post date: [November 9, 2021, 1:32pm UTC](https://discourse.julialang.org/t/how-to-unfold-plots/71196/4 "2021-11-09T13:32:18Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![nilshg](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nilshg/32/2283_2.png) [@nilshg](https://discourse.julialang.org/u/nilshg)
#### Post date: [November 9, 2021, 3:18pm UTC](https://discourse.julialang.org/t/how-to-unfold-plots/71196/5 "2021-11-09T15:18:07Z")

</div>

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

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

```

while

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

```

---

<div class="post-metadata">

### Author: ![corny85](https://avatars.discourse-cdn.com/v4/letter/c/a88e4f/32.png) [@corny85](https://discourse.julialang.org/u/corny85)
#### Post date: [November 9, 2021, 3:24pm UTC](https://discourse.julialang.org/t/how-to-unfold-plots/71196/6 "2021-11-09T15:24:15Z")

</div>

plot(p…) is working !  
Thanks 🙂

---

<div class="post-metadata">

### Author: ![nilshg](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nilshg/32/2283_2.png) [@nilshg](https://discourse.julialang.org/u/nilshg)
#### Post date: [November 9, 2021, 4:24pm UTC](https://discourse.julialang.org/t/how-to-unfold-plots/71196/7 "2021-11-09T16:24:55Z")

</div>

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](https://stackoverflow.com/questions/68913349/how-can-i-get-multiple-histogram-plots-from-a-dataframe-in-julia/68914287#68914287)
