# Number of rows / columns for facet wrap in AlgebraOfGraphics

**URL:** https://discourse.julialang.org/t/number-of-rows-columns-for-facet-wrap-in-algebraofgraphics/81769
**Category:** Visualization
**Tags:** makie, algebraofgraphics
**Created:** [May 27, 2022, 8:08am UTC](https://discourse.julialang.org/t/number-of-rows-columns-for-facet-wrap-in-algebraofgraphics/81769 "2022-05-27T08:08:29Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Jakob](https://avatars.discourse-cdn.com/v4/letter/j/71c47a/32.png) [@Jakob](https://discourse.julialang.org/u/Jakob)
#### Post date: [May 27, 2022, 8:08am UTC](https://discourse.julialang.org/t/number-of-rows-columns-for-facet-wrap-in-algebraofgraphics/81769/1 "2022-05-27T08:08:29Z")

</div>

Does anyone know of an easy way to specify the number of rows / columns when facet wrapping in AOG?

E.g., in the following example I’d like to specify a 3x2 layout instead of 2x3:

```julia
df = (x=rand(100), y=rand(100), l=rand(["a", "b", "c", "d", "e"], 100))
plt = data(df) * mapping(:x, :y, layout=:l)
draw(plt)

```

 ![grafik](https://global.discourse-cdn.com/julialang/original/3X/0/9/0955018aa0c4b7a386ed6c1c5be8137fae214281.png)

I thought maybe there was some keyword argument that you could pass to `draw`, like

```julia
draw(plt, facet=(;nrow=3))

```

But that doesn’t seem to be possible. Could I override the layout manually somehow?

---

<div class="post-metadata">

### Author: ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://discourse.julialang.org/u/jules)
#### Post date: [May 30, 2022, 6:08pm UTC](https://discourse.julialang.org/t/number-of-rows-columns-for-facet-wrap-in-algebraofgraphics/81769/2 "2022-05-30T18:08:53Z")

</div>

@piever told me there was a method to do it by passing a vector of position tuples as a palette, but I never tried it. Maybe it’s worth opening an issue for it?

---

<div class="post-metadata">

### Author: ![piever](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/piever/32/1815_2.png) [@piever](https://discourse.julialang.org/u/piever)
#### Post date: [May 30, 2022, 7:59pm UTC](https://discourse.julialang.org/t/number-of-rows-columns-for-facet-wrap-in-algebraofgraphics/81769/3 "2022-05-30T19:59:58Z")

</div>

Yeah, for now you have to manually specify a list of positions, eg

```julia
palettes = (layout=[(1, 1), (1, 2), (2, 1), (2, 2), (3, 1)],)
draw(plt, palettes)

```

Definitely worth it to add a more straightforward solution to this. I was thinking something like

```julia
palettes = (layout=wrap(cols=3),)

```

---

<div class="post-metadata">

### Author: ![Jakob](https://avatars.discourse-cdn.com/v4/letter/j/71c47a/32.png) [@Jakob](https://discourse.julialang.org/u/Jakob)
#### Post date: [May 31, 2022, 6:35am UTC](https://discourse.julialang.org/t/number-of-rows-columns-for-facet-wrap-in-algebraofgraphics/81769/4 "2022-05-31T06:35:40Z")

</div>

Thanks, that’s already very helpful. I would probably have expected the option under `facet` instead of `palettes` but the `palettes = (layout=wrap(cols=3),)` also would be nice.

I created a [PR](https://github.com/JuliaPlots/AlgebraOfGraphics.jl/pull/396) to add an example with the manually specified layout to the gallery.
