# Yticks on Makie plots get on top of the legend box

**URL:** <https://discourse.julialang.org/t/yticks-on-makie-plots-get-on-top-of-the-legend-box/84633>\
**Category:** Visualization\
**Tags:** question, plotting, makie\
**Created:** [July 22, 2022, 12:15pm UTC](https://discourse.julialang.org/t/yticks-on-makie-plots-get-on-top-of-the-legend-box/84633 "2022-07-22T12:15:23Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![RayleighLord](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rayleighlord/32/33592_2.png) [@RayleighLord](https://discourse.julialang.org/u/RayleighLord)\
**Post date:** [July 22, 2022, 12:15pm UTC](https://discourse.julialang.org/t/yticks-on-makie-plots-get-on-top-of-the-legend-box/84633/1 "2022-07-22T12:15:23Z")

</div>

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

```julia
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

 ![test](https://global.discourse-cdn.com/julialang/original/3X/7/b/7b321e10ee73379fb6c1bb72e13af322ecc9b0e1.png)

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://discourse.julialang.org/u/jules)\
**Post date:** [July 22, 2022, 3:52pm UTC](https://discourse.julialang.org/t/yticks-on-makie-plots-get-on-top-of-the-legend-box/84633/2 "2022-07-22T15:52:47Z")

</div>

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)`

---

<div class="post-metadata">

**Author:** ![RayleighLord](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rayleighlord/32/33592_2.png) [@RayleighLord](https://discourse.julialang.org/u/RayleighLord)\
**Post date:** [July 22, 2022, 4:16pm UTC](https://discourse.julialang.org/t/yticks-on-makie-plots-get-on-top-of-the-legend-box/84633/3 "2022-07-22T16:16:36Z")

</div>

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()`?

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://discourse.julialang.org/u/jules)\
**Post date:** [July 22, 2022, 4:40pm UTC](https://discourse.julialang.org/t/yticks-on-makie-plots-get-on-top-of-the-legend-box/84633/4 "2022-07-22T16:40:14Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![RayleighLord](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rayleighlord/32/33592_2.png) [@RayleighLord](https://discourse.julialang.org/u/RayleighLord)\
**Post date:** [July 22, 2022, 7:32pm UTC](https://discourse.julialang.org/t/yticks-on-makie-plots-get-on-top-of-the-legend-box/84633/5 "2022-07-22T19:32:18Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://discourse.julialang.org/u/jules)\
**Post date:** [July 22, 2022, 7:42pm UTC](https://discourse.julialang.org/t/yticks-on-makie-plots-get-on-top-of-the-legend-box/84633/6 "2022-07-22T19:42:54Z")

</div>

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