# "Redistribute" makie subplots

**URL:** <https://discourse.julialang.org/t/redistribute-makie-subplots/125402>\
**Category:** Visualization\
**Tags:** makie\
**Created:** [January 30, 2025, 7:42pm UTC](https://discourse.julialang.org/t/redistribute-makie-subplots/125402 "2025-01-30T19:42:02Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Torkel](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/torkel/32/5030_2.png) [@Torkel](https://discourse.julialang.org/u/Torkel)\
**Post date:** [January 30, 2025, 7:42pm UTC](https://discourse.julialang.org/t/redistribute-makie-subplots/125402/1 "2025-01-30T19:42:02Z")

</div>

Say that I have created a Makie figure filling

```julia
fig = Figure()
ax1 = Axis(fig[1, 1]; ...)
ax2 = Axis(fig[1, 2]; ...)
ax3 = Axis(fig[1, 3; ...)
ax4 = Axis(fig[1, 4]; ...)

```

Where I here have a 1x4 set of plots. Is there a way to redistribute this to a 2x2 plot? Even better, is there a Makie function that let’s me “automatically” make a square-ish set of plots from my plots?

I have a case where I add n subplots to a Makie plot. I can loop through idx = 1:n, and add them to a vector. But it would be nice with a way to then compress things a little…

---

<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:** [January 30, 2025, 9:11pm UTC](https://discourse.julialang.org/t/redistribute-makie-subplots/125402/2 "2025-01-30T21:11:32Z")

</div>

You can reposition by doing `fig[1,3] = ax`. You can call `trim!(fig.layout)` to remove excess rows.

For squarish you can do `cols = ceil(Int, sqrt(n))` and then `for (i, j) in fldmod1(idx, cols)`
