# Modify position of axis labels in a PGFPlotsX created with plot()

**URL:** <https://discourse.julialang.org/t/modify-position-of-axis-labels-in-a-pgfplotsx-created-with-plot/100425>\
**Category:** Visualization\
**Tags:** plots, pgfplotsx\
**Created:** [June 15, 2023, 10:41pm UTC](https://discourse.julialang.org/t/modify-position-of-axis-labels-in-a-pgfplotsx-created-with-plot/100425 "2023-06-15T22:41:19Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![andresdrenik](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/andresdrenik/32/35777_2.png) [@andresdrenik](https://discourse.julialang.org/u/andresdrenik)\
**Post date:** [June 15, 2023, 10:41pm UTC](https://discourse.julialang.org/t/modify-position-of-axis-labels-in-a-pgfplotsx-created-with-plot/100425/1 "2023-06-15T22:41:19Z")

</div>

Hi, I’m creating the attached figure with

```julia
pgfplotsx()
p1 = plot(𝕊.Ŵ,𝕊.Ĵ, label = "Efficiency", color = 3, linestyle=:dash, legend = :topright, xguide = L"\hat{W}(\hat{w})", yguide = L"\hat{J}(\hat{w})") #, xguidefontvalign=:top, xguidefonthalign = :right, yguidefonthalign = :right, xguide_position = :right, yguideposition = :top) 
           plot!(𝕊.Ŵ[argmax(𝕊.Ĵ):argmax(𝕊.Ŵ)],𝕊.Ĵ[argmax(𝕊.Ĵ):argmax(𝕊.Ŵ)], label = "Redistribution", color = 3)
           plot!(xticks = ([0.0], ["0"]))
           plot!(yticks = ([0.0], ["0"]))
           plot!([minxlim, 𝕊.Ŵ[argmax(𝕊.Ŵ)]],[𝕊.Ĵ[argmax(𝕊.Ŵ)],𝕊.Ĵ[argmax(𝕊.Ŵ)]], label = "", linewidth = 1, linestyle=:dash, color = :black)
           plot!([𝕊.Ŵ[argmax(𝕊.Ŵ)], 𝕊.Ŵ[argmax(𝕊.Ŵ)]],[minylim,𝕊.Ĵ[argmax(𝕊.Ŵ)]], label = "", linewidth = 1, linestyle=:dash, color = :black)
           plot!([minxlim, 𝕊.Ŵ[argmax(𝕊.Ĵ)]],[𝕊.Ĵ[argmax(𝕊.Ĵ)],𝕊.Ĵ[argmax(𝕊.Ĵ)]], label = "", linewidth = 1, linestyle=:dash, color = :black)
           plot!([𝕊.Ŵ[argmax(𝕊.Ĵ)], 𝕊.Ŵ[argmax(𝕊.Ĵ)]],[minylim,𝕊.Ĵ[argmax(𝕊.Ĵ)]], label = "", linewidth = 1, linestyle=:dash, color = :black)
           scatter!([𝕊.Ŵ[argmax(𝕊.Ŵ)]],[𝕊.Ĵ[argmax(𝕊.Ŵ)]], label = "", color = 1, marker=:square)
           scatter!([𝕊.Ŵ[argmax(𝕊.Ĵ)]],[𝕊.Ĵ[argmax(𝕊.Ĵ)]], label = "", color = 2, marker=:circle)
           plot!(Ŵ_lc,IC_lc, label = "Nash Bargaining", color = 4)
           xlims!((minylim, 1.5*𝕊.Ŵ[argmax(𝕊.Ŵ)]))
           ylims!((minxlim, 1.5*𝕊.Ĵ[argmax(𝕊.Ĵ)]))
           plot!(yticks = ([𝕊.Ĵ[argmax(𝕊.Ĵ)] 𝕊.Ĵ[argmax(𝕊.Ŵ)]], [L"\hat{J}(\hat{w}^{\ast j})", L"\hat{J}(\hat{w}^{\ast h})"]))
           plot!(xticks = ([𝕊.Ŵ[argmax(𝕊.Ĵ)] 𝕊.Ŵ[argmax(𝕊.Ŵ)]], [L"\hat{W}(\hat{w}^{\ast j})", L"\hat{W}(\hat{w}^{\ast h})"]))
savefig(p1, "$pathfigures/x.tikz")

```

This is the result:

 ![Screenshot 2023-06-15 at 5.30.09 PM](https://global.discourse-cdn.com/julialang/original/3X/6/0/607b1b4fe1b98220d0bb417599f3ae43032b05ee.png)

Now I want to move the xaxis labels to the position marked in red. The closest I can get is by adding:

```julia
xguidefonthalign = :right, yguidefonthalign = :right

```

which then produces:

 ![Screenshot 2023-06-15 at 5.39.40 PM](https://global.discourse-cdn.com/julialang/original/3X/8/8/881e1ba5f86c02779e02f4428ae8da6c07347308.png)

As you can see, the gap between the labels and the axis is too big. Is there a way to close that gap? I have tried with annotations (but if I use annotate! then pgfplotsx() does not let met annotate outside the box).

Thanks a lot for any suggestion!
