# Ordering labels across subplots

**URL:** https://discourse.julialang.org/t/ordering-labels-across-subplots/105251
**Category:** General Usage
**Tags:** question, plotting, statsplots
**Created:** [October 20, 2023, 9:21pm UTC](https://discourse.julialang.org/t/ordering-labels-across-subplots/105251 "2023-10-20T21:21:14Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Christopher\_Fisher](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/christopher_fisher/32/26132_2.png) [@Christopher\_Fisher](https://discourse.julialang.org/u/Christopher_Fisher)
#### Post date: [October 20, 2023, 9:21pm UTC](https://discourse.julialang.org/t/ordering-labels-across-subplots/105251/1 "2023-10-20T21:21:14Z")

</div>

Hi,

I would like to add the same label to two subplots. In the example below, the densities and colors are correct, but the label should be `1 2 3 4` for each subplot. Is there a way to correct this issue?

Thanks!

```julia
using Distributions 
using StatsPlots 

x = [[rand(Normal(i,.1),100) rand(Normal(i,.5),100)] for i ∈ 1:4]

density(x, layout=(2,1), label=[1 2 3 4], xlims=(0,6))

```

![example](https://global.discourse-cdn.com/julialang/original/3X/0/a/0a92218efeaaf25cb4aa0e56096daa8fadece879.png)

---

<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: [October 20, 2023, 9:44pm UTC](https://discourse.julialang.org/t/ordering-labels-across-subplots/105251/2 "2023-10-20T21:44:24Z")

</div>

Maybe: `label=[1 1 2 2 3 3 4 4]` ?

---

<div class="post-metadata">

### Author: ![Christopher\_Fisher](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/christopher_fisher/32/26132_2.png) [@Christopher\_Fisher](https://discourse.julialang.org/u/Christopher_Fisher)
#### Post date: [October 20, 2023, 10:03pm UTC](https://discourse.julialang.org/t/ordering-labels-across-subplots/105251/3 "2023-10-20T22:03:23Z")

</div>

That works. Thanks! Maybe a general solution is `repeat(my_labels, inner=n_subplots)'`

Unfortunately, this is not so convenient if `my_label` is non-numeric.

---

<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: [October 20, 2023, 10:11pm UTC](https://discourse.julialang.org/t/ordering-labels-across-subplots/105251/4 "2023-10-20T22:11:15Z")

</div>

> [@Christopher\_Fisher](#):
>
> Unfortunately, this is not so convenient if `my_label` is non-numeric

You can use `permutedims`:  
`permutedims(repeat(my_labels, inner=n_subplots))`
