# pgfplots - number format on axis

How can I force pgfplots to draw my axis ticks labels consistently? I mean instead of 0 a 0.0, instead of 1 a 1.0 in the below image.

EDIT: Code

\documentclass[a4paper,10pt]{scrartcl}
\usepackage[utf8]{inputenc}
\usepackage{graphicx}
\usepackage{pgfplots}
\usepackage{pgfplotstable}
\usepackage{filecontents}
\usepackage{siunitx}

\pgfplotsset{
compat=1.7,
every axis/.append style={
line width=1.25pt,
tick style={line width=1.25pt, color=black, line cap=round}
}
}

\begin{document}

\begin{tikzpicture}
\begin{axis}[
enlarge x limits=0.05,
enlarge y limits=0.05,
try min ticks=4,
max space between ticks=50pt,
y tick label style={
/pgf/number format/.cd,
fixed,
fixed zerofill,
precision=1
},
x tick label style={
/pgf/number format/.cd,
fixed,
fixed zerofill,
precision=2
}
]
\end{axis}
\end{tikzpicture}

\end{document}


I can't attach the data file, so here's a link.

-

You can change the number format using the /pgf/number format keys (there are a lot of options). In this concrete case, you'll want to set fixed, fixed zerofill, precision=1 for the y axis, and precision=2 for the x axis:

\documentclass{article}
\usepackage{pgfplots}
\begin{document}

\begin{tikzpicture}

\begin{axis}[
y tick label style={
/pgf/number format/.cd,
fixed,
fixed zerofill,
precision=1,
/tikz/.cd
},
x tick label style={
/pgf/number format/.cd,
fixed,
fixed zerofill,
precision=2,
/tikz/.cd
}
]
\end{axis}
\end{tikzpicture}

\end{document}

-
I'll get an error. This is, I guess, due to the numbers are very small. They have the expansion 1e-19 or something. Is there a way to deal with that? –  DaPhil Feb 1 '13 at 16:17
@DaPhil: Sorry, I forgot to change the key directory back using /tikz/.cd (PGFPlots was still trying to apply normal tikz options using the /pgf/number format directory. I've edited my answer. –  Jake Feb 1 '13 at 16:40
Thanks a lot, now it works! –  DaPhil Feb 1 '13 at 16:53
I took the liberty of adding a comma , after precision=2. –  Harish Kumar Feb 1 '13 at 23:51
@strpeter: You need to change the directory key back using /tikz/.cd if you later want to apply other options to the labels that don't belong to the /pgf/number format directory (e.g. adding x tick label style=red later on). That's not the case in this code example, but resetting the directory to /tikz anyway can't hurt. –  Jake Jan 9 '14 at 9:07