how can I change the exponential value to decimal?
The key fixed zerofill
only applies numbers that also use the fixed
style (that's a bit confusing). So if you set
\pgfkeys{
/pgf/number format/precision=1,
/pgf/number format/fixed zerofill=true,
/pgf/number format/fixed
}
you'll get the desired output:
\documentclass{article}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
\pgfkeys{
/pgf/number format/precision=1,
/pgf/number format/fixed zerofill=true,
/pgf/number format/fixed
}
\begin{axis}[
ybar, ymax=4, ymin=0,
%enlargelimits=0.10,
legend style={at={(0.5,-0.20)},
anchor=north,legend columns=-1},
ylabel={Surface Roughness (nm)},
xlabel={Substrate},
symbolic x coords={Glass,Silicon,PEN},
xtick=data,
nodes near coords,
nodes near coords align={vertical},
]
\addplot [fill= white] coordinates {(Glass,2.4) (Silicon,1.1) (PEN,1.8)};
\addplot [fill = black] coordinates {(Glass,1.1) (Silicon,0.2) (PEN,1.0)};
\legend{Profilometer,AFM}
\end{axis}
\end{tikzpicture}
\end{document}
A way is to exploit the siunitx
package similarly to: pgfplots: Set exponent of scientific number format for nodes near coords
The code:
\documentclass[png,tikz,border=10pt]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.8}
\usepackage{siunitx}
\begin{document}
\begin{tikzpicture}
\pgfkeys{
/pgf/number format/precision=1,
/pgf/number format/fixed zerofill=true
}
\begin{axis}[
ybar, ymax=4, ymin=0,
%enlargelimits=0.10,
legend style={at={(0.5,-0.20)},
anchor=north,legend columns=-1},
ylabel={Surface Roughness (nm)},
xlabel={Substrate},
symbolic x coords={Glass,Silicon,PEN},
xtick=data,
nodes near coords={\pgfmathfloattofixed{\pgfplotspointmeta}% Convert floating point to fixed point
\num[
round-mode=places,
round-precision = 1,
]{\pgfmathresult}},
nodes near coords align={vertical},
]
\addplot [fill= white] coordinates {(Glass,2.4) (Silicon,1.1) (PEN,1.8)};
\addplot [fill = black] coordinates {(Glass,1.1) (Silicon,0.2) (PEN,1.0)};
\legend{Profilometer,AFM}
\end{axis}
\end{tikzpicture}
\end{document}
The result: