# Makie: Using a theme to set the margin of \`axislegend\`

**URL:** https://discourse.julialang.org/t/makie-using-a-theme-to-set-the-margin-of-axislegend/102600
**Category:** Visualization
**Tags:** makie
**Created:** [August 8, 2023, 12:33pm UTC](https://discourse.julialang.org/t/makie-using-a-theme-to-set-the-margin-of-axislegend/102600 "2023-08-08T12:33:02Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![barucden](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/barucden/32/26154_2.png) [@barucden](https://discourse.julialang.org/u/barucden)
#### Post date: [August 8, 2023, 12:33pm UTC](https://discourse.julialang.org/t/makie-using-a-theme-to-set-the-margin-of-axislegend/102600/1 "2023-08-08T12:33:02Z")

</div>

Hello! Consider the following code:

```julia
using CairoMakie
x = 1:100
y = randn(length(x))

theme = Theme(
    Legend=(
        padding=(50, 10, 10, 10),
        margin=(50, 50, 50, 50)
        )
)
with_theme(theme) do
    fig = Figure(resolution=(300, 300))
    axis = Axis(fig[1, 1], xscale=log2)
    lines!(axis, x, y, label="test")
    axislegend(axis, position=:rb)
    save("test.pdf", fig, pt_per_unit=1)
end

```

It produces this image  
 ![pathmnist](https://global.discourse-cdn.com/julialang/original/3X/9/2/923e7a1beef47646a1ac61b3d93e88c35dcc51b3.png)

Notice that the legend applied `padding` as specified by the theme, yet it ignored `margin`. To set `margin`, one needs to pass it as an argument, `axislegend(..., margin=...)`.

Is that the intended behavior?
