# Lining up angled tick labels on a pgfplots bar plot

I'm trying to produce a bar chart for publication with math text in the tick labels. The most readable layout would be to angle them, but when I do they clash with the axis and are difficult to relate to the correct bar. I've tried padding with \quad spaces, but this pushes them even further from the bar they are supposed to be labelling. Is there a way of offsetting the label positions, or some more elegant solution?

Minimal example:

\documentclass{article}
\usepackage{tikz}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}

\begin{axis}[%
xmin=0.5, xmax=5.5,
xtick={1,2,3,4,5},
xticklabels={
$\textrm{fish}^\textrm{cake}$,$\Delta \textrm{bob}^2$,spoon,$e^{i \pi}+1 = 0$,knife},
x tick label style={rotate=45, anchor=east},
ylabel={Energy / Hadouken mol$^{-1}$}]
(2,20)
(3,40)
(4,-20)
(5,10)};

%% This is just to add a zero line for clarity
color=black,
solid,
forget plot
]
table{
0 0
6 0
};

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


Output:

I can think of two things:

• Anchor the labels at the north east rather than the east. Northeast makes more sense when they are placed diagonally in this way.

• Reduce the spacing around the labels by setting inner sep=0mm.

Result:

Code:

\documentclass{article}
\usepackage{tikz}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}

\begin{axis}[%
xmin=0.5, xmax=5.5,
xtick={1,2,3,4,5},
xticklabels={
$\textrm{fish}^\textrm{cake}$,$\Delta \textrm{bob}^2$,spoon,$e^{i \pi}+1 = 0$,knife},
x tick label style={rotate=45, anchor=north east, inner sep=0mm},
ylabel={Energy / Hadouken mol$^{-1}$}]
(2,20)
(3,40)
(4,-20)
(5,10)};

%% This is just to add a zero line for clarity
color=black,
solid,
forget plot
]
table{
0 0
6 0
};

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

• That's great. Between those two parameters there should be enough control for most things. Cheers! – Adam J May 7 '13 at 17:55