I’m trying to make a figure which features a horizontal colorbar. I would like the title of the colorbar to be placed directly to the right of the colorbar, instead of above/below.
I’ve seen this post but using this messed up the layout of the rest of the figure.
Is that possible? Or is there a simple fix that does not affect the curent layout?
How did it mess up the layout of the rest of the figure?
You could alternatively try halign = :left, width = 0. I’m not 100% sure but I’d predict that this leaves the label location as is, but doesn’t affect the layout because the element now looks like it doesn’t have any width.
Ah, the Right side should be in the same column where your colorbar is. So f[2, 3, Right()]. Otherwise you add a new full column, as you’ve noted. Right refers to the protrusion or gap space on the right side of that layout column.
Ah, ok I see, the problem is that the colorbar spans across three columns but only uses part of that width. The protrusion space starts at the actual end of column 3 though, so there’s a gap.
Use a nested gridlayout at the position where the colorbar is now, then put the colorbar at [1, 1] in that layout and the label at [1, 1, Right()]. The column width of that inner layout will shrink to the colorbar’s width, making the label correctly positioned while still leaving the colorbar centered. If you put the label in column 2 of the nested layout, the colorbar would not be centered anymore.