# Adding nodes near coordinates to bar plot but from different series

I would like to annotate a bar plot with some markers or numbers to indicate the significance of some results. The significance is given in a different column from the main value.

Just to give an example of more or less what I would like to do:

\documentclass{standalone}

\usepackage{pgfplots}
\usepackage{pgfplotstable}

1    10 0.84     50 0.75      10    0.22     30 0.24
2    40 0.38     60 0.96     15 0.42     90 0.28
3    20 0.42     60 0.42     15 0.24     60 0.86
}\mytable

\begin{document}%
\begin{tikzpicture}
\begin{axis}[
ybar,enlarge x limits=0.2,bar width=7pt,xtick={1,2,3,4}
]
\addplot table [x index=0,y index=1] {\mytable};
\addplot table [x index=0,y index=3] {\mytable};
\addplot table [x index=0,y index=5] {\mytable};
\addplot table [x index=0,y index=7] {\mytable};
\end{axis}
\end{tikzpicture}
% I would like to mark bars where adjacent value is greater than 0.95
% more specifically: column 2 for value 2

% I would also like to add a different mark where adjacent value is greater than 0.85 (but less than 0.95)
% more specifically: column 4 for value 3
\end{document}


The exact marks are not important; this is just to give the idea.

I know nodes near coords may help here, but I don't know how to get this from a different series.

(Also with the formatting of my plot (the above is just an example) I don't believe I will have room to give the actual values, rather I'll probably want to convert the values to some sort of mark on the bar. I understand this is a different question though so I'm interested in focusing on the first problem.)

• – John Kormylo Apr 30 '16 at 19:28
• Thanks John. That's useful but in my case I have over 400 bars and will have to manually mark over 120. I'm thus hoping for a more automated solution. :) – badroit Apr 30 '16 at 19:48
• I just found this question, which seems relevant: tex.stackexchange.com/questions/80012/… (just trying to adapt it to my problem) – badroit Apr 30 '16 at 20:01
• If you want to automate the process, use a foreach loop and \pgfplotstablegetelem. – John Kormylo Apr 30 '16 at 21:35

Here is a suggestion using point meta=explicit symbolic, nodes near coords and every node near coord/.append style.

\documentclass{standalone}
\usepackage{pgfplots}
\usepackage{pgfplotstable}

1    10 0.84     50 0.75      10    0.22     30 0.24
2    40 0.38     60 0.96     15 0.42     90 0.28
3    20 0.42     60 0.42     15 0.24     60 0.86
}\mytable

\begin{document}%
\begin{tikzpicture}
\begin{axis}[
ybar,enlarge x limits=0.2,bar width=7pt,xtick={1,2,3,4},
point meta=explicit symbolic,
nodes near coords={
\ifdim \pgfplotspointmeta pt > 0.95pt
\textcolor{green}{\huge$\bullet$}%
\else
\ifdim \pgfplotspointmeta pt > 0.85pt
\textcolor{green!50!blue!50}{\huge$\bullet$}%
\fi\fi
},
every node near coord/.append style={inner sep=0pt,anchor=center}
]
\addplot table [x index=0,y index=1,meta index=2] {\mytable};
\addplot table [x index=0,y index=3,meta index=4] {\mytable};
\addplot table [x index=0,y index=5,meta index=6] {\mytable};
\addplot table [x index=0,y index=7,meta index=8] {\mytable};
\end{axis}
\end{tikzpicture}
\end{document}


Result:

or with

\begin{axis}[
ybar,enlarge x limits=0.2,bar width=7pt,xtick={1,2,3,4},
point meta=explicit symbolic,
nodes near coords={
\ifdim \pgfplotspointmeta pt > 0.95pt
\textcolor{green}{\huge$\star$}%
\else
\ifdim \pgfplotspointmeta pt > 0.85pt
\textcolor{green!50!blue!50}{\huge$\star$}%
\fi\fi
}
]


• I spent ages at this and eventually gave up. This is awesome help, thanks a million! – badroit May 1 '16 at 5:24