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}
Best Answer
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: