5

This question has already been answered for axis here but I have troubles to apply the approach to groupplots (please see %additional code in MWE). If I uncomment the %additional code the code is compiled correctly but the number formatting is not as I want it to be (thousands sep=. (or empty) and decimal sep=,) Maybe it has nothing to do with each other but I don't understand why I get the following message:

Package pgfkeys Error: I do not know the key '/pgfplots/use comma' and I'm going to ignore it. Perhaps you misspelled it.

MWE:

\documentclass{article}
\usepackage{pgfplots}
\usepgfplotslibrary{groupplots} 

\begin{document}

\begin{figure}[htbp]
\label{fig:PlotDemand}
\centering
\begin{tikzpicture}
    \begin{groupplot}[

        group style={
            group size=2 by 2,
            vertical sep= 1.5cm,
            every axis y label/.style={at={(ticklabel cs:0.5)},rotate=90,anchor=near ticklabel}
        },
       /pgf/number format/.cd,%additional code
       use comma,%additional code
       1000 sep={},%additional code
        footnotesize,
        xtick={42,44,46,48}

]
    \nextgroupplot[title=\#1]
        \addplot[blue] coordinates{(42, 255) (43, 1584) (44, 1296) (45, 432) (46, 972) (47, 540) (48, 1104) (49, 0)};
    \nextgroupplot[title=\#2]
        \addplot[blue] coordinates{(42, 400) (43, 400) (44, 0) (45, 400) (46, 0) (47, 0) (48, 0) (49, 0)};
    \nextgroupplot[title=\#3]
        \addplot[blue] coordinates{(42, 1800) (43, 2100) (44, 1800) (45, 900) (46, 2100) (47, 2100) (48, 2100) (49, 0)};
    \nextgroupplot[title=\#4]
        \addplot[blue] coordinates{(42, 6800) (43, 2800) (44, 2800) (45, 2800) (46, 2000) (47, 2800) (48, 0) (49, 0)};
    \end{groupplot}
\end{tikzpicture}
\end{figure}


\end{document}
John
  • 1,953
  • In the manual on p. 225 I found a hint and in connection with the answer to the quoted question I could solve the problem with yticklabel style={/pgf/number format/.cd,use comma,1000 sep={}}. Still, maybe there is another approach. – John Oct 19 '12 at 21:50
  • 1
    I gave you the correct preamble here, except for the comma which I removed in the edit. However, four digit numbers shouldn't be separated, according to ISO recommentadions. This is why I set min exponent for 1000 sep=4 there. – Luigi Oct 20 '12 at 07:38

2 Answers2

5

To have a space as a thousands separator, you need to add this to the preamble:

\pgfkeys{/pgf/number format/.cd,%additional code
       use comma,%additional code
       1000 sep={\,},%additional code
}

This should not be part of the groupplot options. If you don't want a space, you can use 1000 sep={}.

If you wish to limit the scope of this setting it can be done within the tikzpicture environment.

Peter Grill
  • 223,288
2

After removing blank lines and adjusting the code slightly it does work …

\documentclass{article}
\usepackage{pgfplots}
\usepgfplotslibrary{groupplots} 

\begin{document}

\begin{figure}[htbp]
\label{fig:PlotDemand}
\centering
\begin{tikzpicture}
    \begin{groupplot}[
        group style={
            group size=2 by 2,
            vertical sep= 1.5cm,
            every axis y label/.style={at={(ticklabel cs:0.5)},rotate=90,anchor=near ticklabel}
        },
%       /pgf/number format/use comma,   % Solution 1
%       /pgf/number format/1000 sep={}, %
        yticklabel style={/pgf/number format/.cd,use comma, 1000 sep={}}, % Solution 2
%        every y tick label/.append style={/pgf/number format/.cd,use comma, 1000 sep={}}, % same as Solution 2
        footnotesize,
        xtick={42,44,46,48}
]
    \nextgroupplot[title=\#1]
        \addplot[blue] coordinates{(42, 255) (43, 1584) (44, 1296) (45, 432) (46, 972) (47, 540) (48, 1104) (49, 0)};
    \nextgroupplot[title=\#2]
        \addplot[blue] coordinates{(42, 400) (43, 400) (44, 0) (45, 400) (46, 0) (47, 0) (48, 0) (49, 0)};
    \nextgroupplot[title=\#3]
        \addplot[blue] coordinates{(42, 1800) (43, 2100) (44, 1800) (45, 900) (46, 2100) (47, 2100) (48, 2100) (49, 0)};
    \nextgroupplot[title=\#4]
        \addplot[blue] coordinates{(42, 6800) (43, 2800) (44, 2800) (45, 2800) (46, 2000) (47, 2800) (48, 0) (49, 0)};
    \end{groupplot}
\end{tikzpicture}
\end{figure}
\end{document}
Qrrbrbirlbel
  • 119,821