# Grid layouts stopped working with 3D Axis

**URL:** <https://discourse.julialang.org/t/grid-layouts-stopped-working-with-3d-axis/82059>\
**Category:** Visualization\
**Tags:** makie\
**Created:** [June 1, 2022, 1:54pm UTC](https://discourse.julialang.org/t/grid-layouts-stopped-working-with-3d-axis/82059 "2022-06-01T13:54:47Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![juliohm](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/juliohm/32/215266_2.png) [@juliohm](https://discourse.julialang.org/u/juliohm)\
**Post date:** [June 1, 2022, 1:54pm UTC](https://discourse.julialang.org/t/grid-layouts-stopped-working-with-3d-axis/82059/1 "2022-06-01T13:54:47Z")

</div>

This grid layout code used to work in 2D and 3D:

```julia
using Meshes, MeshViz
import CairoMakie as Mke

# define a cube in R^3
points = Point3[(0,0,0),(1,0,0),(1,1,0),(0,1,0),(0,0,1),(1,0,1),(1,1,1),(0,1,1)]
connec = connect.([(1,4,3,2),(5,6,7,8),(1,2,6,5),(3,4,8,7),(1,5,8,4),(2,3,7,6)])
mesh = SimpleMesh(points, connec)

# refine three times
ref1 = refine(mesh, CatmullClark())
ref2 = refine(ref1, CatmullClark())
ref3 = refine(ref2, CatmullClark())

fig = Mke.Figure(resolution = (800, 800))
viz(fig[1,1], mesh, showfacets = true, axis = (title = "original",))
viz(fig[1,2], ref1, showfacets = true, axis = (title = "refine 1",))
viz(fig[2,1], ref2, showfacets = true, axis = (title = "refine 2",))
viz(fig[2,2], ref3, showfacets = true, axis = (title = "refine 3",))
fig

```

Now it breaks with the following error message:

```julia
ERROR: MethodError: no method matching initialize_block!(::Makie.MakieLayout.LScene; title="original")
Closest candidates are:
  initialize_block!(::Makie.MakieLayout.LScene; scenekw) at ~/.julia/packages/Makie/fEZv2/src/makielayout/blocks/scene.jl:17 got unsupported keyword argument "title"
  initialize_block!(::Makie.MakieLayout.Axis3) at ~/.julia/packages/Makie/fEZv2/src/makielayout/blocks/axis3d.jl:3 got unsupported keyword argument "title"
  initialize_block!(::Makie.MakieLayout.Label) at ~/.julia/packages/Makie/fEZv2/src/makielayout/blocks/label.jl:3 got unsupported keyword argument "title"
  ...
Stacktrace:
 [1] kwerr(::NamedTuple{(:title,), Tuple{String}}, ::Function, ::Makie.MakieLayout.LScene)
   @ Base ./error.jl:163
 [2] _block(::Type{Makie.MakieLayout.LScene}, ::Makie.Figure; bbox::Nothing, kwargs::Base.Pairs{Symbol, String, Tuple{Symbol}, NamedTuple{(:title,), Tuple{String}}})
   @ Makie.MakieLayout ~/.julia/packages/Makie/fEZv2/src/makielayout/blocks.jl:395
 [3] #_#38
   @ ~/.julia/packages/Makie/fEZv2/src/makielayout/blocks.jl:269 [inlined]
 [4] plot(P::Type{MakieCore.Combined{MeshViz.viz}}, gp::GridLayoutBase.GridPosition, args::SimpleMesh{3, Float64, Vector{Point3}, FullTopology{Connectivity{Quadrangle{Dim, T} where {Dim, T}, 4}}}; axis::NamedTuple{(:title,), Tuple{String}}, kwargs::Base.Pairs{Symbol, Bool, Tuple{Symbol}, NamedTuple{(:showfacets,), Tuple{Bool}}})
   @ Makie ~/.julia/packages/Makie/fEZv2/src/figureplotting.jl:77
 [5] viz(::GridLayoutBase.GridPosition, ::Vararg{Any}; attributes::Base.Pairs{Symbol, Any, Tuple{Symbol, Symbol}, NamedTuple{(:showfacets, :axis), Tuple{Bool, NamedTuple{(:title,), Tuple{String}}}}})
   @ MeshViz ~/.julia/packages/MakieCore/oBlaS/src/recipes.jl:33

```

I understand it has to do with the creation of the grid layout in place. How to update this code to make it work with latest Makie?

This is the offending line where the error is thrown:

```julia
viz(fig[1,1], mesh, showfacets = true, axis = (title = "original",))

```

Notice that it works fine when the recipe produces a 2D Axis.

---

<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:** [June 1, 2022, 2:30pm UTC](https://discourse.julialang.org/t/grid-layouts-stopped-working-with-3d-axis/82059/2 "2022-06-01T14:30:21Z")

</div>

That’s because LScene doesn’t have a title, it’s just a wrapped `Scene` that can be used in a layout. Before, nonexistant keywords like `title` were silently ignored and now they throw an error.

---

<div class="post-metadata">

**Author:** ![juliohm](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/juliohm/32/215266_2.png) [@juliohm](https://discourse.julialang.org/u/juliohm)\
**Post date:** [June 1, 2022, 2:48pm UTC](https://discourse.julialang.org/t/grid-layouts-stopped-working-with-3d-axis/82059/3 "2022-06-01T14:48:33Z")

</div>

Thank you @jules what would be the minimum change to make the code compatible with the latest version? For 2D these commands work fine as explained and the title is placed there correctly.

---

<div class="post-metadata">

**Author:** ![sdanisch](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sdanisch/32/1406_2.png) [@sdanisch](https://discourse.julialang.org/u/sdanisch)\
**Post date:** [June 1, 2022, 2:50pm UTC](https://discourse.julialang.org/t/grid-layouts-stopped-working-with-3d-axis/82059/4 "2022-06-01T14:50:38Z")

</div>

Maybe use Axis3, which has a similar interface as Axis with title etc?

---

<div class="post-metadata">

**Author:** ![juliohm](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/juliohm/32/215266_2.png) [@juliohm](https://discourse.julialang.org/u/juliohm)\
**Post date:** [June 1, 2022, 3:03pm UTC](https://discourse.julialang.org/t/grid-layouts-stopped-working-with-3d-axis/82059/5 "2022-06-01T15:03:35Z")

</div>

How to do that @sdanisch ? Is there a concise version like the one above where we index directly into the figure object? It is super convenient to create the grid on the fly like above.

---

<div class="post-metadata">

**Author:** ![sdanisch](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sdanisch/32/1406_2.png) [@sdanisch](https://discourse.julialang.org/u/sdanisch)\
**Post date:** [June 1, 2022, 3:06pm UTC](https://discourse.julialang.org/t/grid-layouts-stopped-working-with-3d-axis/82059/6 "2022-06-01T15:06:32Z")

</div>

`plot(fig[1,1], axis=(type=Axis3,))`

---

<div class="post-metadata">

**Author:** ![juliohm](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/juliohm/32/215266_2.png) [@juliohm](https://discourse.julialang.org/u/juliohm)\
**Post date:** [June 1, 2022, 3:15pm UTC](https://discourse.julialang.org/t/grid-layouts-stopped-working-with-3d-axis/82059/7 "2022-06-01T15:15:08Z")

</div>

Is there a version that is agnostic to 2D vs. 3D?

---

<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:** [June 1, 2022, 4:02pm UTC](https://discourse.julialang.org/t/grid-layouts-stopped-working-with-3d-axis/82059/8 "2022-06-01T16:02:12Z")

</div>

Just don’t pass a title keyword anymore? It can’t have showed up before either because there never was one for LScene
