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.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I managed to get the x tick labels on the top axis of a plot, but the label of the x axis is still on the bottom axis. I couldn't find an option to get it to the top axis. Is this possible?

Minimal example


    \begin{axis}[xticklabel pos=right, xlabel={My x label}]
      \addplot coordinates { (1,1) (42,23) };

x label is rendered on bottom axis

share|improve this question
Why not xticklabel pos=upper? Interesting... – percusse Nov 30 '11 at 15:26
:-) yeah, I tried that before, but it didn't work. I thought my version was too old and left it at pos=right. I tried it again just now and it worked. Must have been a typo back then. – Flogo Nov 30 '11 at 15:45
up vote 7 down vote accepted

You can add the xlabel near ticks option to get the label above the plot.

\begin{axis}[xticklabel pos=right, xlabel={My x label}, xlabel near ticks]
share|improve this answer

The requested feature has been added after pgfplots version 1.2.1 . Adding


into the preamble will solve the problem globally.

In fact, this has the same effect as described by whlt3: it sets xlabel near ticks (among other keys).

share|improve this answer

Your Answer


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.