Controlling gaps between Axis3 areas in Makie

I am trying to show xy-, xz-, yz-views of a 3D object using Makie. Here is the code to set up three panels for the views:

using CairoMakie
fig =  Figure(resolution=(1500,1500))
fig[1,1] = Axis3(fig, aspect=:data, viewmode=:fit, elevation=π/2, azimuth=-π/2)
fig[2,1] = Axis3(fig, aspect=:data, viewmode=:fit, elevation=0.0, azimuth=-π/2)
fig[2,2] = Axis3(fig, aspect=:data, viewmode=:fit, elevation=0.0, azimuth=0.0)
Box(fig[1,1], color=:transparent, strokecolor=:red)
Box(fig[2,1], color=:transparent, strokecolor=:red)
Box(fig[2,2], color=:transparent, strokecolor=:red)
resize_to_layout!(fig)
display(fig)

And here is the result:


I would like to reduce the gap between the Axis3 areas. I have two issues: the gaps between the black x-, y-, z-axes and the enclosing red rectangles are too wide, and the gaps between red rectangles are two wide. How can I reduce these gaps? I tried to change all the keyword arguments of Axis3 whose names include pad, gap, margin, but none of them works.

For the gaps between rectangles, you can set colgap!(fig.layout, 0) and rowgap!(fig.layout, 0). As for the protrusions which cause the red boxes to be as large as they are, I’m not sure what you could do there.

You might also try setting viewmode = :fitzoom instead of :fit?

1 Like

You can use Axis for the 2D view, and rotate! the objects such that the side you want faces forward. Axis3 doesn’t look good when it’s rotated like that, although I guess you could hide the extraneous axis elements. Axis3 has a protrusions attribute which you have to change manually to improve the gaps. It’s currently not done automatically because the correct values would change with the rotation of the axis.