Adding units to pgfplots nodes in column chart
By default nodes near coords
prints \pgfmathprintnumber{\pgfplotspointmeta}
. You can add a percent sign by saying
nodes near coords=\pgfmathprintnumber{\pgfplotspointmeta}\%
\documentclass{article}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
symbolic x coords={A,B,C},
nodes near coords=\pgfmathprintnumber{\pgfplotspointmeta}\%,
xtick=data
]
\addplot[ybar,fill=blue] coordinates {
(A,34)
(B,22)
(C,13)
};
\end{axis}
\end{tikzpicture}
\end{document}
- Based on Text nodes for nodes near coords I added a custom/explicit
point meta
. - Of course, Torbjørn T. answer is better since you don't have to repeat the values.
\documentclass{article}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
% https://tex.stackexchange.com/questions/350129
\begin{axis}[
symbolic x coords={A,B,C},
nodes near coords,
point meta=explicit symbolic,
xtick=data,
]
\addplot[ybar,fill=blue] coordinates {
(A,34) [34 \%]
(B,22) [22 \%]
(C,13) [13 \%]
};
\end{axis}
\end{tikzpicture}
\end{document}