2

How can I make the thousand separator work for x tick labels when I use symbolic x coordinates for labels? For some reason that setting is not affecting the output at all. Note that by default I use old style numbers but in the figures the numbers can be new style. Any ideas how to fix this?

Below is a minimal example. The y tick lables have a proper separator, but x labels don't.

\documentclass[10pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{pgfplotstable}
\usepackage{lmodern,textcomp}
\usepackage[sc,osf]{mathpazo}

\pgfplotsset{compat=1.15}

\begin{document}
\begin{tikzpicture}
\begin{axis}[
    y tick label style={
        /pgf/number format/1000 sep=\,},
    x tick label style={
        /pgf/number format/1000 sep=\,},
    symbolic x coords={$1000$, $5000$},
    xtick=data,
    ybar
]
    \addplot coordinates {($1000$, 1000) ($5000$, 1200)};
\end{axis}
\end{tikzpicture}
\end{document}

1 Answer 1

5

Not sure why you expect that that setting would affect the labels. Symbolic coordinates are just that, symbolic, so I wouldn't think they're parsed by the number parser (they could after all be text). That said, seems you can use e.g. \pgfmathprintnumber{5000} as a symbolic coordinate, and then the number format applies.

\documentclass[10pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{pgfplotstable}
\usepackage{lmodern,textcomp}
\usepackage[sc,osf]{mathpazo}

\pgfplotsset{compat=1.15}

\begin{document}
\begin{tikzpicture}
\begin{axis}[
    y tick label style={
        /pgf/number format/1000 sep=\,},
    x tick label style={
        /pgf/number format/1000 sep=\,},
    symbolic x coords={\pgfmathprintnumber{1000}, \pgfmathprintnumber{5000}},
    xtick=data,
    ybar
]
    \addplot coordinates {(\pgfmathprintnumber{1000}, 1000) (\pgfmathprintnumber{5000}, 1200)};
\end{axis}
\end{tikzpicture}
\end{document}
1
  • Great, thanks, works exactly as needed!
    – Paapaa
    Oct 20, 2019 at 18:52

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .