# Problem using margin on plots

**URL:** <https://discourse.julialang.org/t/problem-using-margin-on-plots/16226>\
**Category:** General Usage\
**Created:** [October 12, 2018, 11:19am UTC](https://discourse.julialang.org/t/problem-using-margin-on-plots/16226 "2018-10-12T11:19:55Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![IljaK91](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/iljak91/32/44301_2.png) [@IljaK91](https://discourse.julialang.org/u/IljaK91)\
**Post date:** [October 12, 2018, 11:19am UTC](https://discourse.julialang.org/t/problem-using-margin-on-plots/16226/1 "2018-10-12T11:19:55Z")

</div>

Hey everyone,

I have the following problem. I want to plot something and use the Unicode symbol for beta as xlabel. However, it gets cut off like this:

```julia
using Plots; pyplot();
plot(rand(10))
xlabel!("\beta") 

```

![image](https://global.discourse-cdn.com/julialang/original/3X/f/e/fe66f2352c15b3fce1ca56da4b4f865d4e87cb01.png)

It seems to me, that I should adjust the bottom margin like this:

```julia
using Plots; pyplot();
plot(rand(10), bottom_margin = 10mm)
xlabel!("\beta") 

```

like in the documentation here: [http://docs.juliaplots.org/latest/examples/pyplot/#layouts-margins-label-rotation-title-location](http://docs.juliaplots.org/latest/examples/pyplot/#layouts-margins-label-rotation-title-location)

This gives me however the following error:

```julia
<strong>UndefVarError: mm not defined</strong>

in top-level scope at [base\none](#)

```

Does anybody know what to do?

Thanks a lot!

---

<div class="post-metadata">

**Author:** ![Jordan\_Cluts](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jordan_cluts/32/13753_2.png) [@Jordan\_Cluts](https://discourse.julialang.org/u/Jordan_Cluts)\
**Post date:** [October 12, 2018, 12:00pm UTC](https://discourse.julialang.org/t/problem-using-margin-on-plots/16226/2 "2018-10-12T12:00:15Z")

</div>

I have ran into this problem before! There is some package or something you have to enable to be able to use the mm notation. I will try to remember what it is (although someone might beat me to the punch).

---

<div class="post-metadata">

**Author:** ![Jordan\_Cluts](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jordan_cluts/32/13753_2.png) [@Jordan\_Cluts](https://discourse.julialang.org/u/Jordan_Cluts)\
**Post date:** [October 12, 2018, 12:16pm UTC](https://discourse.julialang.org/t/problem-using-margin-on-plots/16226/3 "2018-10-12T12:16:25Z")

</div>

Found it. Add `using Plots.PlotMeasures` and the mm notation should work.

---

<div class="post-metadata">

**Author:** ![IljaK91](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/iljak91/32/44301_2.png) [@IljaK91](https://discourse.julialang.org/u/IljaK91)\
**Post date:** [October 12, 2018, 12:39pm UTC](https://discourse.julialang.org/t/problem-using-margin-on-plots/16226/4 "2018-10-12T12:39:42Z")

</div>

> [@Jordan\_Cluts](#):
>
> using Plots.PlotMeasures

Thanks, that got rid of the error message, but didn’t solve my problem. Now there is more space below the beta, but its top is still cut off. 😕

---

<div class="post-metadata">

**Author:** ![Jordan\_Cluts](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jordan_cluts/32/13753_2.png) [@Jordan\_Cluts](https://discourse.julialang.org/u/Jordan_Cluts)\
**Post date:** [October 12, 2018, 12:59pm UTC](https://discourse.julialang.org/t/problem-using-margin-on-plots/16226/5 "2018-10-12T12:59:42Z")

</div>

Hmm, this seems to be particular to the PyPlot backend. Other backends increase the margin between the label and axis but PyPlot pads below the label instead. If you try another backend (GR, Plotly, etc.) you can do what you want.

---

<div class="post-metadata">

**Author:** ![1634](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/1634/32/12119_2.png) [@1634](https://discourse.julialang.org/u/1634)\
**Post date:** [December 24, 2019, 3:25pm UTC](https://discourse.julialang.org/t/problem-using-margin-on-plots/16226/6 "2019-12-24T15:25:08Z")

</div>

FYI, how about trying

> gr(display\_type=:inline)

befor plot()?

---

<div class="post-metadata">

**Author:** ![mcmuffin6o](https://avatars.discourse-cdn.com/v4/letter/m/9f8e36/32.png) [@mcmuffin6o](https://discourse.julialang.org/u/mcmuffin6o)\
**Post date:** [September 29, 2023, 11:48pm UTC](https://discourse.julialang.org/t/problem-using-margin-on-plots/16226/7 "2023-09-29T23:48:42Z")

</div>

this doesn’t work for the gr backend :​(

---

<div class="post-metadata">

**Author:** ![Shayan](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/shayan/32/33025_2.png) [@Shayan](https://discourse.julialang.org/u/Shayan)\
**Post date:** [January 23, 2024, 1:11pm UTC](https://discourse.julialang.org/t/problem-using-margin-on-plots/16226/8 "2024-01-23T13:11:18Z")

</div>

It definitely works. I tested this on Plots `v1.39.0`.
