First of all, thank you for your help!
Yes I had seen it before my initial message, but I had dismissed it, too hastily in hindsight, because in all the examples, the widths of the row-1 boxes are the same as those of the row-2 boxes. What I need is best addressed if the widths of row-2 boxes can be dissociated from those of row-1 boxes.
But, prompted by your comment, I looked at the tutorial page once again and this time I spotted panel (b) of the first example, which indeed has a colorbar within the fig[2,1]
box.
I can see that this is one solution, but it’s highly restrictive because the width of the contour plot + colorbar is limited to the width of the box above (fig[1,1]
).
The other solution you offer also works if you move the contour plot to the rightmost position of its box (fig[2,1]
) so that it comes right next to the colorbar. It’s also highly restrictive because the contour plot fig[2,1]
really needs to come below the upper left graph (fig[1,1]
). I’ve modified my initial example as you advise and I paste it at the end of this message.
All this seems to indicate that Makie doesn’t allow for freer layout. It has only gridded layout. Is that right?
It would be nice if it allowed for a non-gridded layout, just to arrange arbitrary boxes more freely in the scene
. (I guess this feature has already been requested in the repository?)
In the meanwhile, I’ll plot row 1 and row 2 separately as two PDF files and combine them in my LaTeX document. In that way, I can get whatever layout I like.
using CairoMakie
func(x,y) = cos(x)*sin(y)
fig = Figure()
ax11 = Axis(fig[1,1])
ax12 = Axis(fig[1,2])
ax21 = Axis(fig[2,1]; aspect=1)
xs = -pi:(pi/16):pi
ys = xs
lines!(ax11, xs, sin.(xs))
lines!(ax12, xs, cos.(xs))
co = contourf!(ax21, xs, ys, func.(xs, reshape(ys,1,:)) )
Colorbar(fig[2,2], co; tellwidth=false, halign=:left)
save("tmp.pdf", fig)