6

I'm having a hard time trying to add trailing zeros to the scientific notation in pgfplots! Has anyone ever done this?!

Combinations of /pgf/number format/precision=2, /pgf/number format/sci and /pgf/number format/fixed zerofill doesn't work:(

My Code is:

\begin{tikzpicture}
\begin{axis}[
    width=\textwidth*0.5,
    height=\textwidth*0.5*0.65,
    xmin=-20, xmax=20, ymin=-800000, ymax=-600000,
    y tick label style={/pgf/number format/sci},
    enlarge x limits=0.08,
    enlarge y limits={value=0.12,upper},
]
\addplot[only marks,yerr] table[x=Angle_Value, y=A_Value, y error=A_Error] {csv/w1_angle_test.txt};
\end{axis}
\end{tikzpicture}

And the image looks like this:

enter image description here

  • 1
    Welcome to TeX.SX! Please help us help you and add a minimal working example (MWE) that illustrates your problem. Reproducing the problem and finding out what the issue is will be much easier when we see compilable code, starting with \documentclass{...} and ending with \end{document}. – Dai Bowen Oct 21 '16 at 10:06
8

The option you are looking for is the sci zerofill option; this is shown in the pgf manual under "number printing". You can change the number of trailing zeros with the precision=1 option.

\documentclass[border=3pt]{standalone}
\usepackage{pgfplots}
\begin{document}

\begin{tikzpicture}
\begin{axis}[xmin=0,
ymin=0.0,
yticklabel style={/pgf/number format/.cd,precision=1,sci,sci zerofill}]

 \addplot [black] coordinates  {
(0,1)
(5,10)
(25,100)};
 \end{axis}
\end{tikzpicture}

\end{document}

enter image description here

  • ..still so much to learn after 6 years of Latex:) – recklax Oct 21 '16 at 10:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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