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 use symbolic x coords={} with commas as decimal separators?

For example, I need to use symbolic x coords={0,1.5,1.3}, which gives full stops as decimal separators. Using use comma does not have an effect (logically, so I have nothing against that).

Minimal working example:

\documentclass[border=2pt]{standalone}
\usepackage[utf8]{inputenc}
\usepackage{pgfplots}

\begin{document}
\begin{tikzpicture}
\begin{axis}[
    symbolic x coords={0,1.5,1.3},
    xtick=data,
    /pgf/number format/.cd,
    use comma,
]
    \addplot coordinates {
        (0, 1)
        (1.5, 2)
        (1.3, 1)
    };
\end{axis}
\end{tikzpicture}
\end{document}
share|improve this question
    
I don't seem to have the necessary version installed, so I can't check it, but my guess would be that you just have to enclose the numbers in braces, i.e. symbolic x coords={0,{1,5},{1,3}} –  celtschk Apr 15 '12 at 12:08
    
The use comma option works fine for me without symbolic x coords. –  Thorsten Donig Apr 15 '12 at 12:09
    
BTW, I just notice that you have a comma after use comma despite no options following. Maybe it works if you remove that? –  celtschk Apr 15 '12 at 12:12
    
@celtschk I am aware of that, but then I would have to enclose portions of the data as well, which is tedious and I can not reasonably automate it. The comma after use comma does not have an effect. –  Harold Cavendish Apr 15 '12 at 12:17
    
@ThorstenDonig I know, but the symbolic coordinates are necessary (the x axis corresponds to time and another quantity while the time is raising but the other quantity is changing in both directions). –  Harold Cavendish Apr 15 '12 at 12:17

1 Answer 1

up vote 8 down vote accepted

As it is, PGFplots thinks that the symbolic coordinates are text strings, so it doesn't apply the number formatting options. To fix this, you can set xticklabel=\pgfmathprintnumber{\tick}, which feeds the strings through the number parser and formats them accordingly:

\documentclass[border=2pt]{standalone}
\usepackage[utf8]{inputenc}
\usepackage{pgfplots}

\begin{document}
\begin{tikzpicture}
\begin{axis}[
    symbolic x coords={0,1.5,1.3},
    xtick=data,
    /pgf/number format/.cd,
    use comma,
    xticklabel=\pgfmathprintnumber{\tick}
]
    \addplot coordinates {
        (0, 1)
        (1.5, 2)
        (1.3, 1)
    };
\end{axis}
\end{tikzpicture}
\end{document}
share|improve this answer
    
Splendid, thank you! –  Harold Cavendish Apr 15 '12 at 18:19

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.