# pgfplots: correlation for data values from file works, but with errors

maybe I do not to see the wood for the trees, but I'm always getting error messages for compiling the following pgf code, while the output looks like the way it should. Does anyone see whats wrong with my code? (download tex-file and test.dat)

\documentclass[
a4paper,
DIV13,
12pt,
oneside,
onecolumn,
]{scrbook}

\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage[ngerman]{babel}

\usepackage{pgfplots}
\usepgflibrary{shapes.geometric}
\usetikzlibrary{patterns,arrows}
\pgfplotsset{%
compat=newest,
every axis legend/.append style={draw=none, font=\scriptsize, column sep=5pt},
ymajorgrids=true,
}

\begin{document}

\begin{figure}[htb]
\centering
\footnotesize
\begin{tikzpicture}
\begin{axis}[
enlargelimits=0.2,
ylabel=Altersgruppe,
xlabel=Lautanzahl pro 150 Wörter,
width=9cm,
height=9cm,
ymin=4,
xmin=460,
xmax=620,
enlarge x limits=0.07,
enlarge y limits=0.07
]

\addplot [black, only marks, mark options={scale=1}, mark=*] file {test.dat};

\end{axis}
\end{tikzpicture}

\caption{correlation}
\label{correlation}
\end{figure}

\end{document}

-
I got it! After changing the files encoding from "Unicode UTF-8" to "Western (Windows Latin 1)" and the end-of-line-format from "Mac (CR)" to "Windows (CRLF)" it compiles without any errors. Does anyone know whats behind all that? – MaKa TaBo Jun 12 '11 at 16:35

## 1 Answer

I backtraced through TeX's step and found that it had problems with the very first entry of test.dat -- instead of 477, it found something strange. A more detailed look into the file revealed that it contained a Byte Order Mark (unicode-specific).

I opened the file in vim and used set nobomb (no byte order mark) and saved the file. Afterwards, it worked.

Apparently, pgfplots does not work with data files containing byte order marks.

Anyway, the Mac file ending has nothing to do with it - and the UTF-8 is also fine, as long as you do not include a byte order mark (but as a side effect, the switch to latin1 also removed the bom).

-