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.

As the MWE shows, the separator for every 1000th count was defined empty (for the lack of a better term) since the first column represents the year.

So running the MWE does not work, since pgfplots does not parse numbers with , as 1000 separators/indicators. I'm a bit confused and would like to reassure if this is the right thought: should every figure in the input file then just consist of numbers and no other character whatsoever?

data01.csv

2006;50,000
2007;100,000

data02.csv

2006;100000
2007;150000

MWE

\documentclass[
a4paper
]{scrartcl}

\usepackage{
tikz,
pgfplots,
amsmath
}

\usepackage[T1]{fontenc}
\usepackage{
lmodern,
textcomp
}

\usetikzlibrary{calc,trees,shadows,positioning,arrows,chains,shapes.geometric,%
    decorations.pathreplacing,decorations.pathmorphing,shapes,%
    matrix,shapes.symbols,patterns,intersections}

\pgfdeclarelayer{background layer}
\pgfdeclarelayer{foreground layer}
\pgfsetlayers{background layer,main,foreground layer}

\def\parsedate#1-#2!{%
    \pgfmathparse{#1+1/12*(1#2-101)}%
}

\begin{document}
\begin{center}
\begin{tikzpicture}
\begin{semilogyaxis}[
    %height=7cm,
        %width=14cm,
    %axis lines*=left,
        ymin=0,
        xmin=2006,
        xlabel={abc},
        ylabel={def},
        enlargelimits=upper,
    /pgf/number format/1000 sep={},
        legend style={at={(0.6,1.2)}},
        stack plots=y,
        %legend columns=4,
        legend cell align=left,
        every axis x label/.style={
                at={(ticklabel* cs:1.02)},
                anchor=west,
                },
        every axis y label/.style={
                at={(ticklabel* cs:1.02)},
                anchor=south,
                },
]
\addplot [mark=*, mark indices={1,6}] table [col sep=semicolon] {data01.csv}
node[pos=0, above right=5pt, fill=white]{257,000}
node[pos=1, anchor=south, yshift=3pt, fill=white]{244,862};
\addlegendentry{Text 1}
\addplot [mark=x, mark indices={1,7}] table [col sep=semicolon] {data02.csv}
node[pos=0, above right=5pt, fill=white]{2.000}
node[pos=1, above right=5pt, fill=white]{1.998};
\addlegendentry{Text 2}
\end{semilogyaxis}
\end{tikzpicture}
\end{center}
\end{document}
share|improve this question

1 Answer 1

up vote 3 down vote accepted

You should only be applying this 1000's separator definition to the printing of your tick marks on the x axis. For this use x tick label style or equivalently xticklabel style. In any case this is not affecting reading from the input file. For that, you can tell pgf to ignore commas via an ignore chars option:

Sample output

\documentclass[
a4paper
]{scrartcl}

\usepackage{
tikz,
pgfplots,
amsmath
}

\usepackage[T1]{fontenc}
\usepackage{
lmodern,
textcomp
}

\pgfplotsset{compat=1.8}

\usetikzlibrary{calc,trees,shadows,positioning,arrows,chains,shapes.geometric,%
    decorations.pathreplacing,decorations.pathmorphing,shapes,%
    matrix,shapes.symbols,patterns,intersections}

\pgfdeclarelayer{background layer}
\pgfdeclarelayer{foreground layer}
\pgfsetlayers{background layer,main,foreground layer}

\def\parsedate#1-#2!{%
    \pgfmathparse{#1+1/12*(1#2-101)}%
}

\begin{document}
\begin{center}
\begin{tikzpicture}
\begin{semilogyaxis}[
        ymin=10,
        xmin=2006,
        xlabel={abc},
        ylabel={def},
        enlargelimits=upper,
        x tick label style={/pgf/number format/1000 sep={}},
        legend style={at={(0.6,1.2)}},
        stack plots=y,
        legend cell align=left,
        every axis x label/.style={
                at={(ticklabel* cs:1.02)},
                anchor=west,
                },
        every axis y label/.style={
                at={(ticklabel* cs:1.02)},
                anchor=south,
                },
]
\addplot [mark=*, mark indices={1,6}] table [col sep=semicolon,ignore chars={\,}] {data01.csv}
node[pos=0, above right=5pt, fill=white]{257,000}
node[pos=1, anchor=south, yshift=3pt, fill=white]{244,862};
\addlegendentry{Text 1}
\addplot [mark=x, mark indices={1,7}] table [col sep=semicolon] {data02.csv}
node[pos=0, above right=5pt, fill=white]{2.000}
node[pos=1, above right=5pt, fill=white]{1.998};
\addlegendentry{Text 2}
\end{semilogyaxis}
\end{tikzpicture}
\end{center}
\end{document}

I have added a compat setting to pgfplots, and replaced ymin=0 by ymin=10, both to suppress warnings.

share|improve this answer
    
Thanks. So how can I apply the 1000's separator definition only to the printin gof the tick marks? –  henry Aug 1 '13 at 14:05
1  
By putting it in the tick label style as I did above. –  Andrew Swann Aug 1 '13 at 14:38
    
Actually, that wasn't the "best" solution, but helped me immensely anyhow. With this I searched around a bit more in the manual and I then found on p. 276 ff in the manual: xticklabel style={/pgf/number format/1000 sep={}},. So thanks! –  henry Aug 1 '13 at 15:37
    
Indeed to just set the style along the x-axis, which I agree is most appropriate here, you should use x tick label style (with spaces) rather than tick label style. –  Andrew Swann Aug 1 '13 at 16:35
1  
You are right, p. 277 shows that both x tick label style and xticklabel style are defined and are the same. –  Andrew Swann Aug 2 '13 at 8:28

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.