3

I don't want the comma as the thousand separator, so in the preamble I set

\pgfplotsset{
    x tick label style={/pgf/number format/.cd, set thousands separator={}}
}

This works OK, but when I try to do a plot, where the xmax is under 0.1, e.g. 0.01, that thousands separator line introduces errors.

Here's the MWE: (if you put xmax to 0.1, it works, at 0.01, it doesn't)

\documentclass{standalone}
\usepackage{tikz}
\usepackage{pgfplots}

\pgfplotsset{       
    compat=1.10,
    width=7cm,
    x tick label style={/pgf/number format/.cd, set thousands separator={}}
}

\begin{document}
\begin{tikzpicture}
    \begin{axis}[
        xmin = 0, xmax =0.01,
        ymin =-200, ymax = -20]
    \addplot coordinates {(0,-20) (0.02,-100)};
    \end{axis} 
\end{tikzpicture}
\end{document}

So how to get both: no comma as thousand separator and working code for small x ranges?

0

1 Answer 1

2

You need to add scaled ticks=false. But then you will need to add fixed,precision=3, too to prevent xtick labels from getting cluttered.

\documentclass{standalone}
\usepackage{tikz}
\usepackage{pgfplots}

\pgfplotsset{
    compat=1.10,
    width=7cm,
    x tick label style={/pgf/number format/.cd,fixed,precision=3, set thousands separator={}}
}

\begin{document}
\begin{tikzpicture}
    \begin{axis}[scaled ticks=false,
        xmin = 0, xmax =0.01,
        ymin =-200, ymax = -20]
    \addplot coordinates {(0,-20) (0.02,-100)};
    \end{axis}
\end{tikzpicture}
\end{document}

enter image description here

3
  • good answer, but is there any way I could have the x labels with exponents? I.e. if you take my MWE code and comment out the line starting with x tick label... and see the result, then that's what I want. So basically I want everything as default except for the thousand separator to be nothing instead of a comma.
    – eimrek
    May 9, 2015 at 15:28
  • @Shepherd Then use /pgf/number format/set thousands separator={} as commented by egreg.
    – user11232
    May 9, 2015 at 15:40
  • 1
    Thanks, now it works perfectly. I don't see any egreg comments though.
    – eimrek
    May 9, 2015 at 16:05

You must log in to answer this question.

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