How to link axes in a Makie figure?

Suppose I have a figure with multiple subfigures:

using GLMakie

fig = Figure()
scatter(fig[1,1], rand(10))
scatter(fig[1,2], rand(10))

How to link all axes in the figure? I am aware of linkaxes! but it expects axes objects as input.

Is there a section of the documentation explaining the relationship between figures, scenes, axes and how to extract one from another?

The figure has a content vector where objects that were created with Axis(f... etc should be stored. So you can filter axes from there. You can also go through the nested layouts but that’s more work. Layouts are kind of decoupled from figures, something can be in a layout but doesn’t have to be in the figure, and vice versa.

f = Figure()
for i in 1:4, j in 1:4
    scatter(f[i, j], randn(10, 2))
end

linkaxes!(filter(x -> x isa Axis, f.content)...)
f

2 Likes

Thank you @jules , am I correct that linking Axis3 is currently not available?

Yes it lacks the infrastructure for that. Also I’m not sure how I would want that to work, and it might need a rework of Axis as well

1 Like

@jules any advance regarding the link of 3D axes?

Nobody has worked on that, no

2 Likes

That would be super cool, but would probably require more work for linking all the observables including the rotation of the axes and so on. What would be the observables, that I need to bind in order to do this? Is there something that would be necessary to “link” besides the axis attributes?

At some point the 3D axes were linked by default. I don’t know what happened in the latest releases, but they are decoupled now.