Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I want to make my plot completely in decimal. I used the function

\pgfkeys{
    /pgf/number format/precision=1, 
    /pgf/number format/fixed zerofill=true
}

to make my decimal like 2.0 instead of only 2. Now I am facing a problem that my value which was 0.2 now changed to 2.0 x10exp2. I want it back to 0.2. Please help. Code and pic is given.<code>plot after using pgfkeys function</code>

\begin{figure}[htb!]
\centering
\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,
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} 
\caption{Substrate Vs IBD Surface Roughness(Avg)}
\label{Subvibd}
\end{figure}
share|improve this question
add comment

2 Answers

up vote 8 down vote accepted

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}
share|improve this answer
    
Thanks Jake......So nice of you...:) problem solved...:) –  Rizwan Jun 17 '13 at 22:01
add comment

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: enter image description here

share|improve this answer
    
Thanks Claudio for your kind reply. Problem is solved :) –  Rizwan Jun 17 '13 at 22:02
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.