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 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

\documentclass{article}
\usepackage{tikz}
\usepackage{pgfplots}

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

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
add comment

2 Answers

up vote 3 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
add comment

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

\pgfplotsset{compat=1.3}

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
add comment

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.