Can someone help me to place these labels above the error bars? And is there any option to show the SDs besides the label?
\documentclass{article}
\usepackage{tikz}
\usepackage{pgfplots}
\pgfplotsset{compat=1.18}
\begin{document}
\usetikzlibrary{patterns}
\begin{tikzpicture}
\begin{axis}[
ybar, axis on top,
height=11cm, width=14.5cm,
bar width=0.4cm,
ybar=3pt,
enlarge y limits={value=.1,upper},
ymin=25, ymax=400,
axis x line*=bottom,
axis y line*=left,
y axis line style={opacity=0},
tickwidth=1pt,
enlarge x limits=true,
ymajorgrids=true,
major grid style={lines,lightgray},
legend style={
at={(0.5,-0.1)},
anchor=north,
legend columns=5,
/tikz/every even column/.append style={column sep=0.5cm}},
ylabel=\textbf{Weekly accumulated load (\% of match)},
symbolic x coords={TD (m),HSR (m),SPR (m),Acc. (\#),Dec. (\#)},
xtick=data,
ticklabel style={/pgf/number format/.cd, use comma, 1000 sep = {}},
nodes near coords,
nodes near coords align={vertical},
nodes near coords={\pgfkeys{/pgf/fpu}\pgfmathparse{\pgfplotspointmeta}\pgfmathprintnumber{\pgfmathresult}\,\%},
every node near coord/.append style={font=\scriptsize, rotate=0, yshift=20},
every axis legend/.append style={font=\scriptsize}],
\addplot[draw=none, postaction={pattern=north east lines}, fill=white, error bars/.cd,y dir=both,y explicit,error bar style={line width=0.1pt}]
coordinates
{
(TD (m), 225) +- (TD (m),24)
(HSR (m),142) +- (HSR (m),31)
(SPR (m), 235) +- (SPR (m),54)
(Acc. (\#), 279) +- (Acc. (\#),38)
(Dec. (\#), 225) +- (Dec. (\#),56)
};
\addplot[draw=none, postaction={pattern=dots},fill=gray, pattern color= black,error bars/.cd,y dir=both,y explicit,error bar style={line width=0.1pt}]
coordinates {
(TD (m), 190) +- (TD (m),18)
(HSR (m),88) +- (HSR (m),20)
(SPR (m), 112) +- (SPR (m),28)
(Acc. (\#), 247) +- (Acc. (\#),40)
(Dec. (\#), 188) +- (Dec. (\#),33)
};
\addplot[draw=none, fill=black, error bars/.cd,y dir=both,y explicit,error bar style={line width=0.1pt}]
coordinates {
(TD (m), 190) +- (TD (m),11)
(HSR (m),123) +- (HSR (m),21)
(SPR (m), 169) +- (SPR (m),39)
(Acc. (\#), 212) +- (Acc. (\#),29)
(Dec. (\#), 158) +- (Dec. (\#),30)
};
\addplot[draw=none, fill=lightgray, error bars/.cd,y dir=both,y explicit, error bar style={line width=0.1pt}]
coordinates {
(TD (m), 199) +- (TD (m),17)
(HSR (m),103) +- (HSR (m),21)
(SPR (m), 116) +- (SPR (m),25)
(Acc. (\#), 253) +- (Acc. (\#),30)
(Dec. (\#), 169) +- (Dec. (\#),18)
};
\legend{CB, WB, CM, CF}
\end{axis}
\end{tikzpicture}
\end{document}
Best Answer
This is a solution based on https://tex.stackexchange.com/a/130318/263192 and https://tex.stackexchange.com/a/200575/263192.
I have moved your data into
pgfplotstable
tables, such that the data can be referenced invisualization depends on
.Unfortunately, this only works up to
compat=1.10
.