Makie Layout Text Over Column of Plots

Hello,

I am trying to show the evolution of a quantity via a series of plots. I have three simulations which describe something changing with time. I want to show side by side comparisons at various times. So my idea is to create a series of panes where each column corresponds to a different simulation and each row corresponds to a different time.

I’d like to place an overall label to each column in addition to each plot pane having a title. I was able to achieve this using newlines and the Label as shown below. It does seem a little hacky but I’m not sure how else to explicitly place Label inside a grid layout.

# mwe.jl
using CairoMakie

begin
    fig = Figure()
    gL = GridLayout(fig[1, 1], 3, 2)
    width = 100
    height = 100
    make_ax = (pane, title) -> Axis(pane, width=width, height=height, title=title)

    ax1 = make_ax(gL[1, 1], "Plot 1")
    ax2 = make_ax(gL[2, 1], "Plot 2")
    ax3 = make_ax(gL[3, 1], "Plot 3")
    ax4 = make_ax(gL[1, 2], "Plot 4")
    ax5 = make_ax(gL[2, 2], "Plot 5")
    ax6 = make_ax(gL[3, 2], "Plot 6")

    mynum = 5

    Box(gL[1:3, 1], color=(:white, 0.0), strokewidth=1.5, cornerradius=5, width=width * 1.5, height=4.5 * height)
    Label(gL[1, 1, Top()], "Column Title = $(mynum)\n\n\n")

    resize_to_layout!(fig)
    fig
end

The problem I am having is that I need to be able to use LaTeXStrings in the Label text and that does not appear to work when I try to concatenate a LaTeXstring with newlines. Apparently it has worked for some folks as described here but it is not working for me. See below.

Using Label(gL[1, 1, Top()], [L"Column Title = $\alpha=%$(mynum)$" * "\n\n\n"]) I get

image

And if I don’t use any newlines then I get text overlaid.

image

I also tried using text! but I don’t know how to place it outside the existing axes. See example below. It is “stuck” inside the Axis. It does correctly display the latex so this seems close to what I want - if only I could place it outside the axis.

Any suggestions would be appreciated.

image

using CairoMakie

begin
    fig = Figure()
    gL = GridLayout(fig[1, 1], 3, 2)
    width = 100
    height = 100
    make_ax = (pane, title) -> Axis(pane, width=width, height=height, title=title)

    ax1 = make_ax(gL[1, 1], "Plot 1")
    lines!(1:10, 1:10)
    ax2 = make_ax(gL[2, 1], "Plot 2")
    ax3 = make_ax(gL[3, 1], "Plot 3")
    ax4 = make_ax(gL[1, 2], "Plot 4")
    ax5 = make_ax(gL[2, 2], "Plot 5")
    ax6 = make_ax(gL[3, 2], "Plot 6")

    mynum = 5

    Box(gL[1:3, 1], color=(:white, 0.0), strokewidth=1.5, cornerradius=5, width=width * 1.5, height=4.5 * height)
    text!(ax1, 5, 10, align=(:center, :center), text=L"Column Title, $\alpha=%$(mynum)$")

    resize_to_layout!(fig)
    fig
end

It sounds like you’d be fine just placing the labels at row 0, then you don’t have to fiddle with linebreaks etc. Just make sure to set tellwidth = false so the columns don’t shrink to the text size. So like Label(gl[0, 1], "Column title ...", tellwidth = false)

Thank you! :slightly_smiling_face: