Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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}
share|improve this question

2 Answers 2

up vote 3 down vote accepted

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}

enter image description here

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.

share|improve this answer
    
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
    }

enter image description here

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}
share|improve this answer
    
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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.