Makie Uneven Legend Banks

Hello,

Is it possible to have uneven number of elements in the banks of a Legend in Makie? Below is an MWE - the actual figure I need this for is crowded and I basically need two legend entries in bank 2 moved into bank 1.

Is that possible? Any ideas on how that could be specified?

In the MWE, how can I have legend entries for plots 1 to 4 in bank 1 and 5 to 6 in bank 2.

begin
    x = LinRange(0, 1, 100)
    y = x .^ 2
    fig = Figure()
    ax = Axis(fig[1, 1])
    for i = 1:6
        lines!(x, i .* y, label="plot $(i)")
    end
    axislegend(position=:lt, nbanks=2, framevisible=false)
    fig
end

Maybe like this?

begin
    x = LinRange(0, 1, 100)
    y = x .^ 2
    fig = Figure()
    ax = Axis(fig[1, 1])
    for i = 1:6
        lines!(x, i .* y, label="plot $(i)")
    end
    axislegend(position=:lt, nbanks=4, framevisible=false, orientation = :horizontal)
    fig
end

Otherwise one could probably work with empty entries to shape the legend into more custom configurations

Do you have any examples handy of how this could be done?

Edit: Also, was just thinking. One way to accomplish this would be to allow users to specify number of entries per bank.

Like this:

begin
    x = LinRange(0, 1, 100)
    y = x .^ 2
    fig = Figure()
    ax = Axis(fig[1, 1])
    lins = map(1:6) do i
        lines!(x, i .* y)
    end
    plts = [lins[1:3]..., [], [], lins[4:6]...]
    labels = ["A", "B", "C", "", "", "D", "E", "F"]
    axislegend(ax, plts, labels; position=:lt, nbanks=2, framevisible=false)
    fig
end

1 Like

Thanks! Although now there are blanks. I was hoping they would be “skipped” so it would look something like this, and pretending that D is also excluded. (excuse the amateur paint skills :sweat_smile:) Hopefully that makes sense. Let me know if not and I will try to be clearer.

The blanks were just for demonstration, but you can do any arrangement with that no?

1 Like

To get that, just add a single blank to the end.