# Is there a way to add padding between axis ticks and axis label in Plots.jl with gr?

**URL:** <https://discourse.julialang.org/t/is-there-a-way-to-add-padding-between-axis-ticks-and-axis-label-in-plots-jl-with-gr/116498>\
**Category:** Visualization\
**Tags:** plotting, plots\
**Created:** [July 2, 2024, 1:26am UTC](https://discourse.julialang.org/t/is-there-a-way-to-add-padding-between-axis-ticks-and-axis-label-in-plots-jl-with-gr/116498 "2024-07-02T01:26:46Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![PeX](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pex/32/49986_2.png) [@PeX](https://discourse.julialang.org/u/PeX)\
**Post date:** [July 2, 2024, 1:26am UTC](https://discourse.julialang.org/t/is-there-a-way-to-add-padding-between-axis-ticks-and-axis-label-in-plots-jl-with-gr/116498/1 "2024-07-02T01:26:46Z")

</div>

Hi all!

I’m using the GR backend to create a plot. The axis label is written with a `LatexString`, but for some reason, there is almost no space between the tick labels and the axis label. I’ve been trying for a while to find a solution but couldn’t. Is there a simple way to deal with this situation?

Thank you!

Edit - my plotting environment looks like this:

```julia
using Plots
using LaTeXStrings
using Distributions

#Plotting function with latex string
function plot_normal(mu, sigma, label_x)
    x = range(mu - 4*sigma, stop=mu + 4*sigma, length=1000)
    y = pdf(Normal(mu, sigma), x)
    
    plot(x, y, label="", linewidth=2)
    xlabel!(label_x)
end

#LateX string label
label_x = L"Normal Distribution: $x$"

#subplot1
plot1 = plot_normal(0, 1, label_x)

#subplot2
plot2 = plot_normal(5, 2, label_x)

#Main plot
combined_plot = plot(plot1, plot2, layout=(1, 2), size=(800, 400))

```

---

<div class="post-metadata">

**Author:** ![rafael.guerra](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rafael.guerra/32/216610_2.png) [@rafael.guerra](https://discourse.julialang.org/u/rafael.guerra)\
**Post date:** [July 2, 2024, 1:34am UTC](https://discourse.julialang.org/t/is-there-a-way-to-add-padding-between-axis-ticks-and-axis-label-in-plots-jl-with-gr/116498/2 "2024-07-02T01:34:46Z")

</div>

As simple as adding a carriage return and margins:

```julia
using Measures, LaTeXStrings, Plots; gr()
plot(sin, xlabel="\nx^2", margins=5mm)

```

---

<div class="post-metadata">

**Author:** ![PeX](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pex/32/49986_2.png) [@PeX](https://discourse.julialang.org/u/PeX)\
**Post date:** [July 2, 2024, 1:38am UTC](https://discourse.julialang.org/t/is-there-a-way-to-add-padding-between-axis-ticks-and-axis-label-in-plots-jl-with-gr/116498/3 "2024-07-02T01:38:42Z")

</div>

Sadly this doesn’t work. Maybe because I have multiple figures? The margins seems to add space between the labels and the edges of the entire figure space. Am I doing something wrong?

---

<div class="post-metadata">

**Author:** ![rafael.guerra](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rafael.guerra/32/216610_2.png) [@rafael.guerra](https://discourse.julialang.org/u/rafael.guerra)\
**Post date:** [July 2, 2024, 2:05am UTC](https://discourse.julialang.org/t/is-there-a-way-to-add-padding-between-axis-ticks-and-axis-label-in-plots-jl-with-gr/116498/4 "2024-07-02T02:05:58Z")

</div>

> [@PeX](#):
>
> Am I doing something wrong?

Yes, not providing a MWE.

---

<div class="post-metadata">

**Author:** ![PeX](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pex/32/49986_2.png) [@PeX](https://discourse.julialang.org/u/PeX)\
**Post date:** [July 2, 2024, 2:14am UTC](https://discourse.julialang.org/t/is-there-a-way-to-add-padding-between-axis-ticks-and-axis-label-in-plots-jl-with-gr/116498/5 "2024-07-02T02:14:43Z")

</div>

Sorry, I added.

---

<div class="post-metadata">

**Author:** ![rafael.guerra](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rafael.guerra/32/216610_2.png) [@rafael.guerra](https://discourse.julialang.org/u/rafael.guerra)\
**Post date:** [July 2, 2024, 8:09am UTC](https://discourse.julialang.org/t/is-there-a-way-to-add-padding-between-axis-ticks-and-axis-label-in-plots-jl-with-gr/116498/6 "2024-07-02T08:09:36Z")

</div>

Please try the following additions/changes to your code:

```julia
using Measures
...
label_x = "\n" * L"Normal Distribution: $x$"
...
combined_plot = plot(plot1, plot2, layout=(1, 2), size=(800, 400), bottommargin=7mm)

```
