Yticks on Makie plots get on top of the legend box

Hello,

Using a customized set of attributes for my plots, I found that the yticks can appear on top of a legend box. For me, this behaviour is highly undesirable but I have not found a way to make the legend box appear on top of the ticks of the axes, so I would like to ask if someone knows hot to do it.

You can find a MWE here

using GLMakie

x = -π:0.1:π
y = sin.(x)

fig = Figure(fontsize = 35, font = "CMU", resolution = (1152, 864),
backgroundcolor = :white,figure_padding = (0, 40, 0, 20), linewidth = 5.0,)
ax = Axis(fig[1, 1], xtickalign = 1, xticksize = 20, ytickalign = 1, yticksize = 20)

lines!(ax, x, y, label="curve")
axislegend(ax; merge=true, position=:lt)
ylims!(-1.1, 1.1)

which produces the figure

Oh that’s just a z value difference that could be tweaked better. I think if you translated the legend forward more it should cover the tick. Or you increase its margin attribute to push it away.

You can try translate!(ax.blockscene, 0, 0, something_high)

Thank you. Actually, now that you mention the margin attribute, I tried it inside the axislegend function and gets the result I want.

However, when creating the custom themes I use inside Theme(), when defining the Legend() attributes, for some reason the attribute margin does not work for me, so I did not know what that attribute really did. Other Legend attributes like bgcolor, framecolor, patchlabelgap, patchsize do work well.

Any idea why using margins inside a Theme for customizing a legend does not have the same effect as when you use it inside axislegend()?

It might be overwritten by axislegend because the default theme for free standing Legends would usually not have margins set, but it looks better inside the Axis.

So there is currently no way of setting the margins in a Theme without them being overwritten, right?

Hmm no it just seems to be hardcoded right now. We currently only have themes for types, not for functions.