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

andresdrenik
Thu, 15 Jun 2023 22:41:19 +0000
Visualization

Hi, I’m creating the attached figure with

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:

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

xguidefonthalign = :right, yguidefonthalign = :right

which then produces:

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!

1 post - 1 participant