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.

How can I change the type of the decimal/thousand separator from the american one to the european one? More precisely, I want:

  • "1000" to be written as is, instead of "1,000"
  • "0,1" instead of "0.1"
share|improve this question

2 Answers 2

up vote 29 down vote accepted

The number formatting is changed using the /pgf/number format keys, which are described starting on page 546 of the pgfmanual. In your case, you would want to set /pgf/number format/use comma to set the comma as the decimal separator, and /pgf/number format/1000 sep={} to suppress separators for the groups of thousands.

When setting several subkeys, you can save yourself a bit of typing by first changing to the main key using /pgf/number format/.cd, and then setting the number formats.

Since I assume you want the number format to be consistent all through your plot, you should set the options for the whole axis.

Here's an example:

\documentclass{article}
\usepackage{pgfplots}

\begin{document}


\begin{tikzpicture}
\begin{axis}[
    /pgf/number format/.cd,
        use comma,
        1000 sep={}]
\addplot +[domain=0:1] {(x+rnd)*4000};
\end{axis}
\end{tikzpicture}

\end{document}

share|improve this answer
    
Do you know if it is possible to have pgfplots(and TikZ) to format numbers like \num{} from the siunitx package (ftp.dante.de/tex-archive/help/Catalogue/entries/siunitx.html). -Like my numbers in the rest of the document. –  Hans-Peter E. Kristiansen Dec 10 '11 at 17:50
2  
@Hans-PeterE.Kristiansen: Yes, you can set xticklabel=\num[round-mode=places,round-precision=1]{\tick} (or similar). –  Jake Dec 11 '11 at 1:24
    
I think a new option like american number format or european number format could be useful here (this is a comment for @ChristianFeuersänger). Otherwise, if one uses siunitx, the number format should be gathered from the options set in that package. –  Luigi Dec 17 '12 at 16:55

Edit: As per Jake's comments: using set decimal separator={,} instead of use comma introduces an unwanted thin space after the comma. Interestingly, if you use set decimal separator={.}, this doesn't happen. So, better to use use comma instead as per Jake's solution.


Use set thousands separator={} and set decimal separator={,} which yields:

enter image description here

\documentclass{article}
\usepackage{pgfplots}

\begin{document}
\begin{tikzpicture}
\begin{axis}[
      y tick label style={/pgf/number format/.cd,%
          scaled y ticks = false,
          set thousands separator={},
          fixed},
      x tick label style={/pgf/number format/.cd,%
          scaled x ticks = false,
          set decimal separator={,},
          fixed}%
     ]
  \addplot coordinates {
  (0.1,1000)
  (0.2,1100)
  (0.3,1200)
  };    
\end{axis}
\end{tikzpicture}
\end{document}
share|improve this answer
    
Use set decimal separator={{,}} to avoid this behavior. –  Patrick Bergner Dec 23 '12 at 18:45
    
@PatrickBergner I have tried this and it is not improving the situation. Any idea? –  Magpie Mar 10 '13 at 14:34
    
@Magpie: Without more details it is difficult to help. I'd suggest posting a new question. You should refer to this question and show exactly how this did not improve the situation. –  Peter Grill Mar 10 '13 at 20:49
    
@PeterGrill it's ok I fixed it. See answer below. Thanks! –  Magpie Mar 10 '13 at 21:27
    
Oh wait.I just noticed that the OP actually wanted this formatting I can't get my head around that but I will delete anyway. –  Magpie Mar 10 '13 at 21:36

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.