# Center Axis in Plot

**URL:** <https://discourse.julialang.org/t/center-axis-in-plot/121015>\
**Category:** Visualization\
**Tags:** plots, gr\
**Created:** [October 7, 2024, 3:43pm UTC](https://discourse.julialang.org/t/center-axis-in-plot/121015 "2024-10-07T15:43:25Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![jamesmulhern](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jamesmulhern/32/212283_2.png) [@jamesmulhern](https://discourse.julialang.org/u/jamesmulhern)\
**Post date:** [October 7, 2024, 3:43pm UTC](https://discourse.julialang.org/t/center-axis-in-plot/121015/1 "2024-10-07T15:43:25Z")

</div>

Does anyone know how to center the axis window when using Plots.jl and the default backend (GR?)

I have been working though all of the attributes and I cannot get it to have equal margins on both sides. I have set `margins=0mm`, as well as `formatter=:none` and `tick_direction=:none`. Please see the image below as an example.

BTW there is a bug (or maybe not) where if `showaxis=false` the space for the axis labels is still reserved. This requires `formatter=:none` to remove.

 ![julia_plot](https://global.discourse-cdn.com/julialang/original/3X/f/b/fb577597a3a7b922ae99ab02651caab309dc50f9.jpeg)  
EDIT: Changed figure to a snip so you can clearly see the edges of the image.

---

<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:** [October 7, 2024, 6:30pm UTC](https://discourse.julialang.org/t/center-axis-in-plot/121015/2 "2024-10-07T18:30:16Z")

</div>

Is the following all right?

 ![test_margins](https://global.discourse-cdn.com/julialang/original/3X/d/e/deed3b33b9681e2f838a818eedf9af0f1de8d9df.png)

---

<div class="post-metadata">

**Author:** ![jamesmulhern](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jamesmulhern/32/212283_2.png) [@jamesmulhern](https://discourse.julialang.org/u/jamesmulhern)\
**Post date:** [October 7, 2024, 7:21pm UTC](https://discourse.julialang.org/t/center-axis-in-plot/121015/3 "2024-10-07T19:21:11Z")

</div>

How did you do this? Increase the margin value?

It is alright, but I would prefer to have very small boarder. Something like the right had side of the image I uploaded.

---

<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:** [October 7, 2024, 7:34pm UTC](https://discourse.julialang.org/t/center-axis-in-plot/121015/4 "2024-10-07T19:34:13Z")

</div>

Ok, I thought you wanted all 4 margins to be the same size, if it is only 3, then it is easier.

This code:

```julia
using Measures, Plots
gr(dpi=600)
plot(sin, ticks=false, framestyle=:box, margins=0mm, title="This is a title")
savefig("test2_margins.png")

```

produces this figure:

 ![test2_margins](https://global.discourse-cdn.com/julialang/original/3X/9/a/9af397c7f07472d319e2f217f5fccff96cfbe9c6.png)

---

<div class="post-metadata">

**Author:** ![jamesmulhern](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jamesmulhern/32/212283_2.png) [@jamesmulhern](https://discourse.julialang.org/u/jamesmulhern)\
**Post date:** [October 8, 2024, 9:04am UTC](https://discourse.julialang.org/t/center-axis-in-plot/121015/5 "2024-10-08T09:04:59Z")

</div>

> [@rafael.guerra](#):
>
> `ticks=false`

This is what I was missing! Thanks
