Thank you all for the advice. Oh, I wish I had a solution between that of @jules and @aramirezreyes …
The problem with @jules solution is that the figures are for publication; they need to have a specific size, otherwise it will messup the font size significantly when inserted into latex, and I really don’t want to deal with hte headache of the fontsize of the figure changing depending on how many letters my legend has…
@aramirezreyes solution is far superior here for the reason that the figure has a fixed size. Unfortunately, all legend entries are grouped in the middle, which appears weird.
By the way, since I know in advance the width of my figure, I could give all axes and the legend a fixed widht, like 700, but this doesn’t give results different from the @aramirezreyes solution:
f = Figure(resolution = (750, 500))
axs = map(1:2) do i
ax = Axis(f[i+1, 1]; width = 700)
lines!(ax, cumsum(randn(100)), label = "periodic")
lines!(ax, cumsum(randn(100)), label = "quasiperiodic")
lines!(ax, cumsum(randn(100)), label = "Koch snowflake")
lines!(ax, cumsum(randn(100)), label = "Kaplan-Yorke map")
lines!(ax, cumsum(randn(100)), label = "sphere")
lines!(ax, cumsum(randn(100)), label = "SM (uniform)")
return ax
end
Legend(f[1, 1], axs[1], nbanks = 3, tellheight = true, width = 700)
f
having an evenly spaced out legend regardless of width seems like a nice feature to have, especially for publications. The situation I am trtying to achieve is common in papers I believe.