# How to add another row of tick labels?

Rather than adding a second x axis by putting it on the other side of the plot I would like to add one implicitly simply by adding another row of tick labels to an existing axis. What I am after is something like the following mockup:

Using the idea in this answer I have tried to come up with something like this but there are some problems and maybe there is a better approach to the issue?

\documentclass{article}

\usepackage{pgfplots}

\pgfplotsset{
domain=0:1,
xmin=0, xmax=1,
ymax=1, ymin=0
}

\begin{document}

\begin{figure}
\begin{tikzpicture}
\begin{axis}[xtick align=inside,
extra x ticks={0.2, 0.4, ..., 0.8},
extra x tick labels={0.33, 0.33, 0.33, 0.33},
every extra x tick/.style={
xtick align=outside,
},
xlabel=$$x_1$$,
after end axis/.code={
\node  at (rel axis cs:1,0) [anchor=south west, align=left] {$$x_2$$};
}
]
\end{axis}
\end{tikzpicture}
\end{figure}

\end{document}

-

Using major tick length=0pt for the every extra x tick style, you can get rid of the ticks for the extra labels; you can prevent the overlapping using a yshift; using the axis description coordinate system you can place $$x_1$$ and $$x_2$$:

\documentclass{article}
\usepackage{pgfplots}

\pgfplotsset{
domain=0:1,
xmin=0, xmax=1,
ymax=1, ymin=0
}

\begin{document}

\begin{figure}
\begin{tikzpicture}
\begin{axis}[xtick align=inside,clip=false,
extra x ticks={0, 0.2, 0.4, ..., 1},
extra x tick labels={0.33, 0.33, 0.33, 0.33, 0.33,0.33},
every extra x tick/.style={major tick length=0pt,
xtick align=outside,yshift=-10pt}
]
\node  at (axis description cs:0,0) [anchor=north east, align=left,xshift=-12pt] {$$x_1$$};
\node  at (axis description cs:0,0) [anchor=north east, align=left,xshift=-12pt,yshift=-11pt] {$$x_2$$};
\end{axis}

\end{tikzpicture}
\end{figure}

\end{document}


-
Thanks this does what I want for single plots. However when I use it with groupplots the position of x1 and x2 is not right. –  N.N. Aug 6 '12 at 15:02
@N.N. please add to your question a minimal example. –  Gonzalo Medina Aug 6 '12 at 15:06
I was wrong in what caused it. You can reproduce it by setting the plotted function to another, e.g. change to \addplot{x - 0.5}; and you can see that x1 and x2 are displaced. –  N.N. Aug 6 '12 at 15:17
@N.N. I've updated my answer; using the axis description coordinate system should fix the problem. –  Gonzalo Medina Aug 6 '12 at 15:40
Cheers! Is it possible to get it go work without clip=false? Without clip some functions, e.g. \addplot{ln(1 / x)};, grows outside the axis. A fix might be to use restrict y to domain=-1:1, but I dunno if it is the right way to go. –  N.N. Aug 6 '12 at 16:00