[Tex/LaTex] marking statistically significant results in bar graph using pgfplots

pgfplots

I'm making a bar chart with pgfplots and would like to put an asterisk above some bars to show statistical significance (p < 0.05). Any ideas?

Here's an example graph:

\begin{tikzpicture}
\begin{axis}[
    symbolic x coords={(a),(b),(c),(d),(e)},
    xtick=data]
    \addplot[ybar] coordinates {
        ((a),51365) % I'd like to put an asterisk above some of these
        ((b),74531)
        ((c),52862)
        ((d),78999)
        ((e),71825)
    };
\end{axis}
\end{tikzpicture}

Best Answer

I would use the nodes near coords functionality together with point meta=explicit symbolic for this:

\documentclass[border=5mm]{standalone}

\usepackage{pgfplots}

\begin{document}
\begin{tikzpicture}
\begin{axis}[
    symbolic x coords={(a),(b),(c),(d),(e)},
    xtick=data,
    ymin=0,
    point meta=explicit symbolic,
    nodes near coords    
    ]
    \addplot[ybar] table [meta index=2, header=false] {
       (a) 51365 *
       (b) 74531 \\
       (c) 52862 *
       (d) 78999 \\
       (e) 71825 \\
    };
\end{axis}
\end{tikzpicture}

\end{document}