Grid layouts stopped working with 3D Axis

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

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:

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:

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

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

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.

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.

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

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.

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

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

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

1 Like