# pgfplots with 2 x axis, misalignment of upper x xticklabels

I need a plot with two x-axes, on at the top the other at the bottom. I try to do this quite successfully with this example code:

\documentclass[12pt,twoside, a4paper]{report}
\usepackage[german]{babel}
\usepackage[T1]{fontenc}
\usepackage[latin1]{inputenc}
\usepackage{tikz}
\usepackage{pgfplots}
\pgfplotsset{compat=1.6}
\begin{document}

\begin{tikzpicture}
%\pgfplotsset{set layers}%Not used
width=5.41cm,
height=4.415cm,
xmin=-7.5,xmax=7.5,ymin=0.01,ymax=50,
axis x line*=bottom,
xtick={-6,-4,-2,0,2,4,6},
enlargelimits=false,axis on top=true,
xlabel=lower x scale,ylabel=y scale]
(-6,0.1) (0,10) (6,0.2)};
\end{semilogyaxis}

scale only axis,
width=5.41cm,
height=4.415cm,
xmin=-0.7409,xmax=0.7409,ymin=0.01,ymax=50,
minor tick num=3,
axis x line*=top,
axis y line=none,
enlargelimits=false,axis on top=true,
xlabel=upper x scale]
\end{semilogyaxis}
\end{tikzpicture}
\end{document}


The result is quite nice, as you can see here:

But due to the '-0.5' on the upper left corner there is a slight misalignment of the labels. How can I get rid of this problem?

-

The minus sign has a greater text depth than the other characters in the labels, causing the misalignment. You can set text depth=0pt to fix this:

\documentclass[12pt,twoside, a4paper]{report}
\usepackage[german]{babel}
\usepackage[T1]{fontenc}
\usepackage[latin1]{inputenc}
\usepackage{tikz}
\usepackage{pgfplots}
\pgfplotsset{compat=1.6}
\begin{document}

\begin{tikzpicture}
%\pgfplotsset{set layers}%Not used
width=5.41cm,
height=4.415cm,
xmin=-7.5,xmax=7.5,ymin=0.01,ymax=50,
axis x line*=bottom,
xtick={-6,-4,-2,0,2,4,6},
enlargelimits=false,axis on top=true,
xlabel=lower x scale,ylabel=y scale]
(-6,0.1) (0,10) (6,0.2)};
\end{semilogyaxis}

scale only axis,
width=5.41cm,
height=4.415cm,
xmin=-0.7409,xmax=0.7409,ymin=0.01,ymax=50,
xticklabel style={text depth=0pt},
minor tick num=3,
axis x line*=top,
axis y line=none,
enlargelimits=false,axis on top=true,
xlabel=upper x scale]
\end{semilogyaxis}
\end{tikzpicture}
\end{document}

-
Do you know why the minus sign needs such a depth? It looks like it could be avoided –  Spike Oct 28 '12 at 18:41
Thanks a lot for this easy, well working trick!! –  partial81 Oct 28 '12 at 20:16