# How to layout figures in CairoMakie after they are generated

**URL:** <https://discourse.julialang.org/t/how-to-layout-figures-in-cairomakie-after-they-are-generated/61683>\
**Category:** Visualization\
**Tags:** makie\
**Created:** [May 23, 2021, 2:42pm UTC](https://discourse.julialang.org/t/how-to-layout-figures-in-cairomakie-after-they-are-generated/61683 "2021-05-23T14:42:33Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![vjd](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/vjd/32/2644_2.png) [@vjd](https://discourse.julialang.org/u/vjd)\
**Post date:** [May 23, 2021, 2:42pm UTC](https://discourse.julialang.org/t/how-to-layout-figures-in-cairomakie-after-they-are-generated/61683/1 "2021-05-23T14:42:33Z")

</div>

_Note: Question on slack that I reposting here for wider audience._

Is there a way to layout figures in CairoMakie after they are generated? e.g. I have

```julia
julia> typeof(a1)
Figure

julia> typeof(a2)
Figure

```

I want to snap these together horizontally or vertically, basically layout `Figure` s  
(I know I can do this while generating the actual figure, but curious if there was a layout option)

---

<div class="post-metadata">

**Author:** ![vjd](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/vjd/32/2644_2.png) [@vjd](https://discourse.julialang.org/u/vjd)\
**Post date:** [May 23, 2021, 2:44pm UTC](https://discourse.julialang.org/t/how-to-layout-figures-in-cairomakie-after-they-are-generated/61683/2 "2021-05-23T14:44:07Z")

</div>

The answer below was posted by @sdanisch . this would be a useful feature in the ecosystem IMO.

“I made a little helper function for that some time ago”

```julia
function reparent(f::AbstractPlotting.FigurePosition, fig)
    ax = Axis(f.fig; fig.axis.attributes...)
    f.gp[] = ax
    for p in fig.axis.scene.plots
        plot!(ax, typeof(p), p.attributes, p.input_args...)
    end
    return ax
end
f = Figure()
reparent(f[1, 1], fig)
reparent(f[1, 2], fig2)
display(f)

```

---

<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 23, 2021, 4:20pm UTC](https://discourse.julialang.org/t/how-to-layout-figures-in-cairomakie-after-they-are-generated/61683/3 "2021-05-23T16:20:53Z")

</div>

Does that do what you want though? It seems an axis gets created and stuff replotted into it, but what about figures that have multiple axes, colorbars, etc? Also, a normal figure doesn’t even have an `axis` field, maybe this was meant for a `FigureAxisPlot` only
