# How to start using the thousands separator in pgfplots for numbers >= 10000 only?

When using a half space (\,) as the thousangs separator it is common to only start using it for numbers larger than 10000. This is reflected, e.g., in the siunitx package:

• \SI{1000} becomes 1000
• \SI{12345} becomes 12 345

However, pgfplots appears to only offer

\pgfkeys{/pgf/number format/.cd,1000 sep={\,}}

which adapts the thousands separator for all groups of three digits. Is there a way to change this behavior, matching the one specified above?

Use this

\pgfkeys{/pgf/number format/.cd,int detect,1000 sep={\,},min exponent for 1000 sep=4}


Check the page 33 of this document http://pgfplots.sourceforge.net/pgfplotstable.pdf. Hope I've helped you!

MWE:

\documentclass{article}
\usepackage{pgfplots}

\begin{document}

\pgfkeys{/pgf/number format/.cd,int detect,1000 sep={\,},min exponent for 1000 sep=4}
\pgfmathprintnumber{1000};
\pgfmathprintnumber{10000}

\end{document}


• Seems like a good answer. Please add an MWE to allow easy testing, and you'll have my upvote. Mar 5, 2020 at 17:50
• I updated the answer @frougon. Hope it works! Mar 5, 2020 at 19:08
• Yes, though I would replace the two lines\usepackage{pgfplots} \pgfplotsset{compat=1.9} with just \usepackage{pgf}. (BTW, compat=1.9 seems very old). Maybe the OP will need an example that affects only the tick labels of a plot... but it's the OP's fault not to have provided a MWE with a plot. Thanks for this update, anyway. Mar 5, 2020 at 19:25
• I usually use pgfplots with compat=1.9 because I have some problems with the latest versions with old graphs, but yeah, you are right! Mar 5, 2020 at 19:36