Is there a way to specify that node near coords
labels should use
1 rather than 2 decimal places?
For example, in the code below,
Singapore is printed with 8.1 (correct),
but Niger is printed with 46.12 (wrong)
when I want it instead to be 46.1 (correct).
\documentclass{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.12}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
xlabel={Birth rate (births/1,000 population)},
symbolic y coords={Niger,United States,Singapore},
ytick=data,
xbar,
nodes near coords, nodes near coords align={horizontal}]
\addplot coordinates {
(46.12,Niger)
(13.42,United States)
(8.10,Singapore)
};
\end{axis}
\end{tikzpicture}
\end{document}
Best Answer
Use
or
With
fixed zerofill
a value like4.00
will be printed as4.0
.Code: