# How to prevent rounded and duplicated tick labels in pgfplots with fixed precision?

I have a plot whose y axis is linear with fixed precision and without scaling.

\documentclass{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.11}

\begin{document}
\begin{tikzpicture}
\begin{axis}[domain=-0.1:0.1,
yticklabel style={scaled ticks=false,
/pgf/number format/fixed,
/pgf/number format/precision=3}]
\end{axis}
\end{tikzpicture}
\end{document}


The y tick labels are very little expressive because pgf rounded 0.0005 to 0.001 in the middle, producing contradictive labels. I do not really want to increase the precision (space constraints on the page), so apparently the best solution is to remove the middle "(-)0.001" ticks. Is there a pgfplots option to achieve this? One that says "do not place ticks such that the label gets rounded", "minimum difference between labels should be 0.001" or similar.

There are literally 100 similar plots in my document coming from data which is subject to change, so manually specifying the y ticks is not the preferred option.

• I would prefer them not to be scaled, because 100 plots, each with different scaling, would be confusing. But yes, maybe adding some (fixed?) scaling is the best solution if what I want to do isn't possible. – Sören Schulze Jun 6 '15 at 15:17

One possibility is to compare whether the trimmed version is different than the original tick number. But this is quite a general spec so if your other 99 plots have different strange intervals I don't think this would be foolproof

\documentclass{standalone}
\pgfplotsset{compat=1.12}
\begin{document}
\begin{tikzpicture}
\begin{axis}[domain=-0.1:0.1,
yticklabel style={scaled ticks=false,
/pgf/number format/fixed,
/pgf/number format/precision=3},
yticklabel={%
\pgfmathprintnumberto[verbatim,fixed,precision=3]{\tick}\possiblytrimmedtick%
\pgfmathparse{\possiblytrimmedtick == \tick ? int(1):int(0)}%
\ifnum\pgfmathresult>0\relax$\tick$\else\fi%
}
]