Does BBox work with GridLayout?

I want to create a graph with multiple axis and move them across the plot. I worked perfectly with Figure(), but do not work with GridLayout(), which I need to make combined figure.

How can I solve this problem?

How it should be:

How it is now:

The code before:


begin
    times = range(-0.3, length=size(dat_e, 2), step=1 ./ 128)

    f = Figure()
    for i in 1:30
        xmove = pos[i][1] *1000 - 120
        ymove =  pos[i][2]  * 800 - 100
        ax = Axis(f, bbox = BBox(xmove, xmove+90, ymove, ymove+30), title = string(raw.ch_names[i]))
        mean_trial = mean(dat_e[i,:,:], dims=2)[:,1]
        lines!(ax, times, mean_trial,  color = "#0077b6") #, model = m4x4)
        hlines!(0, color = :gray, linewidth = 1)
        vlines!(0, color = :gray, linewidth = 1)
        hidespines!(ax) 
        hidedecorations!(ax)
        Makie.ylims!(low = -8, high = 14)
    end
    f
end

The code now:

function topo_array(f) 
    times = range(-0.3, length=size(dat_e, 2), step=1 ./ 128)
    
    for i in 1:30
        xmove = pos[i][1] *1000 - 120
        ymove =  pos[i][2]  * 800 - 100
        ax = Axis(f[1, 1], bbox = BBox(xmove, xmove+90, ymove, ymove+30), title = string(raw_ch_names[i]))
        mean_trial = mean(dat_e[i,:,:], dims=2)[:,1]
        lines!(ax, times, mean_trial,  color = "#0077b6") #, model = m4x4)
        hlines!(0, color = :gray, linewidth = 1)
        vlines!(0, color = :gray, linewidth = 1)
        hidespines!(ax) 
        hidedecorations!(ax)
        Makie.ylims!(low = -8, high = 14)
    end
    f
end
topo_array(GridLayout())

I can’t run the code since variables are missing…
Can you update so I can try this out?

How about this code:

using UnfoldMakie
using Unfold
using CairoMakie
using DataFrames


begin 
	df, pos = example_data("TopoPlots.jl")
	df = filter(x -> (x.channel <= 32),  df)
	ch_vector = [
		"FP1", "F3", "F7", "FC3", "C3", "C5", "P3", "P7", "P9", "PO7",
		"PO3", "O1", "Oz", "Pz", "CPz", "FP2", "Fz", "F4", "F8", "FC4",
		"FCz", "Cz", "C4", "C6", "P4", "P8", "P10", "PO8", "PO4", "O2"
	]
	f = Figure(backgroundcolor=RGBf(0.98, 0.98, 0.98),
    resolution=(1000, 700))
	ga = f[1, 1] = GridLayout()
	gb = f[2, 1] = GridLayout()
	gcd = f[1:2, 2] = GridLayout()
	gc = gcd[1, 1] = GridLayout()
	gd = gcd[2, 1] = GridLayout()
	gef = f[1:2, 3] = GridLayout()
	ge = gef[1, 1] = GridLayout()
	gf = gef[2, 1] = GridLayout()

	function topo_array(f) 
	
		for i in 1:30
			tmp = filter(x -> (x.channel == i),  df)

			xmove = pos[i][1] *1000 - 120
			ymove =  pos[i][2]  * 800 - 100
			ax = Axis(f[1, 1], bbox = BBox(xmove, xmove+90, ymove, ymove+30), title = ch_vector[i])
			lines!(ax, df.time, df.estimate,  color = "#0077b6") #, model = m4x4)
			hlines!(0, color = :gray, linewidth = 1)
			vlines!(0, color = :gray, linewidth = 1)
			hidespines!(ax) 
			hidedecorations!(ax)
			Makie.ylims!(low = -8, high = 14)
		end
		
		f
	end

	topo_array(gf)
	f
end

When you use bbox you manually say which rectangle in the Figure or Scene you want to place a Block in. This does not work together with assigning the Block to a specific layout position, because then that layout position will decide where the object ends up. I can see two paths forward. Either you try ls = LScene(gridposition; camera = campixel!) and then you do Axis(ls.scene, bbox = ...) or you check what rectangle a given GridLayout occupies, by looking into glayout.layoutobservables.computedbbox and then computing your desired positions within that rectangle.