# TikZ: Replacing the values (labels) on x-axis with names

I managed to create a simple linear plot with pgfplots-manual (chapter 4.5.1)

Now I want to replace the values of x-axis (1,2,3,4) with text, e.g.Test A, Test B, Test C, Test D. How can I do such a configuration?

MWE:

    \documentclass[12pt,ngerman]{article}
\usepackage{pgfplots}
\pgfplotsset{width=7cm,compat=1.10}

\begin{document}

\begin{tikzpicture}
\begin{axis}
[
xlabel={Test},
ylabel={Mean}
]
{(0,18.26) (1,21.47) (2,24.58) (3,24.95)};
\end{axis}
\end{tikzpicture}

\end{document}


You have to rename the already existing tick labels. Therefore you define the position of the ticks (one tick for each data point as seen below or ticks in a certain pattern as seen in the commented line) by xtick= and rename their labels by xticklabels=.

% arara: pdflatex

\documentclass[12pt]{article}
\usepackage{pgfplots}
\pgfplotsset{compat=1.10}

\begin{document}
\begin{tikzpicture}
\begin{axis}
[
,width=7cm
,xlabel=Test
,ylabel=Mean
,xtick=data,
%,xtick={0,1,...,3}
,xticklabels={Test A,Test B,Test C,Test D}
]
{(0,18.26) (1,21.47) (2,24.58) (3,24.95)};
\end{axis}
\end{tikzpicture}
\end{document}


• Additional problem: if my labels are too long, they overlap - is there a possible solution or do I have to use abbrevations? – Jens Jun 27 '14 at 15:39
• you may enlarge the width or you rotate your labels (x tick label style={rotate=90,anchor=east}). – LaRiFaRi Jun 27 '14 at 15:40