I did an ANOVA with 4 tests. Result graph is shown here, original code comes from: TikZ: Replacing the values (labels) on x-axis with names

\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}


Problem: I want to add additional lines which indicate the results of pairwise comparisions as displayed in the example below:

1. I could manually arrange further lines - is there a more elegant way?

2. How do I add the *** and ** near the lines?

3. How do I get a dotted line with arrows as endings?

-
as displayed in the example below... is something missing from your question? – cmhughes Jun 29 '14 at 19:28
The graph was missing, now it's included :) – Jens Jun 29 '14 at 19:36

For this specific case a quick and easy way is to add something like

\draw [dotted,->] ([xshift=0.3cm]axis cs:0,18.26) -- ([yshift=-0.3cm]axis cs:2,24.58) node[near end,right,font=\tiny]{***};
\draw [dotted,->,shorten >=0.3cm] (axis cs:0.2,18.26) -- (axis cs:3,24.95) node[near end,right,font=\tiny]{**};


just before \end{axis}.

• dotted,-> specifies that the line should be dotted and have the default arrow head.

• A coordinate such as axis cs:0,18.26 means that the coordinate system of the axis should be used. When [xshift=0.3cm] is placed at the start of the coordinate as in ([xshift=0.3cm]axis cs:0,18.26) it moves the coordinate 0.3cm to the right. Similarly for yshift.

• node[near end,right,font=\tiny]{**} places a node to the right of the line, near the end, and sets it with \tiny font size.

• shorten >=0.3cm cuts off 0.3cm at the end of the line.

Note that all the coordinates used are the same as those of the plot itself, so the lines are drawn relative to them.

\documentclass[12pt,border=4mm]{standalone}
\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}
]

@Jens use -stealth instead of ->. – Torbjørn T. Jun 29 '14 at 22:37