# pgfplot axis xlabel right justified at east end of axis

I would like to draw an x axis with the axis label not centered, but on the right side of the axis. Something like anchor=east and pos=east for the xlabel. Is this possible?

Simple example:

\documentclass{standalone}
\usepackage{tikz}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}

\begin{axis}[xlabel=$p_{T} (GeV/c)$, ylabel=abundance, ymode=log]
\end{axis}

\end{tikzpicture}
\end{document}

-

## 2 Answers

This is actually an answer to your follow-up comment posted after @Peter's answer: you asked how to keep the vertical position while moving only the horizontal one.

Here is how to proceed:

\documentclass[border=5pt]{standalone}
\usepackage{tikz}
\usepackage{pgfplots}
\pgfplotsset{compat=1.7}

\begin{document}
\begin{tikzpicture}
\begin{axis}[xlabel=$p_{T} (GeV/c)$, ylabel=abundance, ymode=log,
xlabel style={
at={(ticklabel cs:1)},
anchor=north west,
},%
]
\end{axis}
\end{tikzpicture}
\end{document}


Attention: I also added \pgfplotsset{compat=1.7}. It is generally best-practise to write a compat level of at least 1.3. If you have a document which is more than 4 years old and you want to keep its label positions (i.e. you do not want to write the compat key), I can post a slightly different answer.

The default axis placement (as of version 1.3) is at={(ticklabel cs:0.5)},anchor=near ticklabel. The 0.5 means to place it in the middle of the (respective) axis. In your case, I said 1 to indicate that it should use the upper end, and I wrote an anchor as requested. The ticklabel cs takes care of the size of tick labels.

-
Perfect, that's excactly what I was looking for. Thanks a lot! – user24520 Mar 23 '13 at 13:40

You can include a style for the xlabel:

xlabel style={
at={(current axis.right of origin)},
xshift=7.5ex, anchor=center
}


## Code:

\documentclass[border=5pt]{standalone}
\usepackage{tikz}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}

\begin{axis}[xlabel=$p_{T} (GeV/c)$, ylabel=abundance, ymode=log,
xlabel style={
at={(current axis.right of origin)},
xshift=7.5ex, anchor=center
}]
\end{axis}

\end{tikzpicture}
\end{document}

-
Thanks, it's getting closer. Modifying your example I get what I want. But I would have liked to keep the vertical position unchanged instead of forcing it with the yshift. \begin{axis}[xlabel=$p_{T} (GeV/c)$, ylabel=abundance, ymode=log, xlabel style={ at={(current axis.right of origin)}, yshift=-4.5ex, anchor=east }] \end{axis} – user24520 Mar 20 '13 at 22:51