# Set x tick label position to bottom of the axis

I have finally managed to center my data with axis x line*=center, but I haven't found a way to get my x tick labels at the bottom of the figure. I have already drawn some major grid lines and now I want my tick labels to be at the bottom of my figure.

I have tried to use at={()}, but that did not seem to work.

\documentclass{standalone}
\usepackage{pgfplots}

\begin{document}
\begin{tikzpicture}

\begin{axis}[ybar=0,
bar width={0.2cm},
xticklabels from table={\datatable}{variable},
xtick=data,
x tick label style={
rotate=60,anchor=east},
xmajorgrids,
ymin=-2,
ymax=2,
axis x line*=middle,
axis y line*=left,
enlarge x limits,
y filter/.code={\pgfmathparse{#1-3}}
]

\end{axis}
\end{tikzpicture}
\end{document}


Example data:

X   variable                    old         new
1   {Know where I am}           2.375       4
2   {Know what I see}           3.375       4.375
3   {See target directly}       2.428571429 4.5
4   {Know origin}               3.875       4.285714286
5   {Direct Adjustment (inv)}   2.625       3.75
6   {Screen position}           3.25        4.125
7   {Expectation}               2.25        2.375
8   {Get lost (inv)}            2.714285714 3.5
9   {Number dependent (inv)}    2           4

-

The easiest thing to do here is to use axis x line*=left (instead of middle), which will place the axis line and the labels at the bottom of the plot, and to "fake" the zero line using one of the approaches from How can I add a zero line to a plot?.

For this graph, may I suggest flipping the axes around? That would make it much easier to read the labels, since you can do without the rotation:

Code for first solution

\documentclass[border=5mm]{standalone}
\usepackage{pgfplots}

\begin{document}
\begin{tikzpicture}
X   variable                    old         new
1   {Know where I am}           2.375       4
2   {Know what I see}           3.375       4.375
3   {See target directly}       2.428571429 4.5
4   {Know origin}               3.875       4.285714286
5   {Direct Adjustment (inv)}   2.625       3.75
6   {Screen position}           3.25        4.125
7   {Expectation}               2.25        2.375
8   {Get lost (inv)}            2.714285714 3.5
9   {Number dependent (inv)}    2           4
}\datatable

\begin{axis}[ybar=0,
bar width={0.2cm},
xticklabels from table={\datatable}{variable},
xtick=data,
x tick label style={
rotate=60,anchor=east},
xmajorgrids,
ymin=-2,
ymax=2,
axis x line*=left,
axis y line*=left,
enlarge x limits,
y filter/.code={\pgfmathparse{#1-3}},
after end axis/.code={\draw ({rel axis cs:0,0}|-{axis cs:0,0}) -- ({rel axis cs:1,0}|-{axis cs:0,0});}
]

\end{axis}
\end{tikzpicture}
\end{document}


Code for second solution

\documentclass[border=5mm]{standalone}
\usepackage{pgfplots}

\begin{document}
\begin{tikzpicture}
X   variable                    old         new
1   {Know where I am}           2.375       4
2   {Know what I see}           3.375       4.375
3   {See target directly}       2.428571429 4.5
4   {Know origin}               3.875       4.285714286
5   {Direct Adjustment (inv)}   2.625       3.75
6   {Screen position}           3.25        4.125
7   {Expectation}               2.25        2.375
8   {Get lost (inv)}            2.714285714 3.5
9   {Number dependent (inv)}    2           4
}\datatable

\begin{axis}[xbar=0,
bar width={0.2cm},
yticklabels from table={\datatable}{variable},
ytick=data,
xmajorgrids,
xmin=-2,
xmax=2,
axis x line*=left,
axis y line*=left,
enlarge x limits,
x filter/.code={\pgfmathparse{#1-3}},
after end axis/.code={\draw ({rel axis cs:0,0}-|{axis cs:0,0}) -- ({rel axis cs:0,1}-|{axis cs:0,0});},
legend style={at={(1,0.9)}}
]


I would like to know if I'm doing a good job inserting yticklabels={X,Very Bad, Bad, Neutral, Good, Very Good}. It seems a little hacky with the X in front, but that was the only way to get it working somehow. – Marnix Jun 16 '12 at 15:37
@Marnix: You can avoid the dummy label by specifying the y tick positions: ytick={-2,...,2}, yticklabels={Very Bad, Bad, Neutral, Good, Very Good} – Jake Jun 16 '12 at 15:40