4

I'm trying to visualize some data with TikZ datavisualization library. Given foo.tex

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{datavisualization}

\begin{document}
\begin{tikzpicture}
  \datavisualization [ scientific axes, visualize as scatter ] data [ read from file=foo.dat ];
\end{tikzpicture}
\end{document}

and foo.dat:

x, y
1, 2
3, 4
5, 6

It fails with the following error (repeated multiple times):

! Package PGF Math Error: Sorry, an internal routine of the floating point unit got an ill-formatted floating point number `'. The unreadable part was near ''..

See the PGF Math package documentation for explanation.
Type  H <return>  for immediate help.
 ...                                              

l.7 ... scatter ] data [ read from file=foo.dat ];

If I'd rather include data from foo.dat inline the document compiles normally. What am I missing and how can I fix the problem?

I'm running TeXLive 2014 on Windows 7. All files use Unix line ending.

EDIT: I've removed all commas in my data file and explicitly set separator to \space, now it works.

One more quertion: TikZ documentation says:

/pgf/data/separator=<character> (no default, initially ,)

What does this mean? What is the difference between initial value and default value?

4

I'd consider removing the header from foo.dat. If you determine the header internally, there's less margin for error apparently (though I'm surprised by the error as well). It's an easy solution that works for files with large amounts of data as well. A working file looks like this:

http://i.imgur.com/Wegmu2H.png?1

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{datavisualization}

\begin{document}
\begin{tikzpicture}
  \datavisualization [ scientific axes, visualize as scatter ] data [headline={x, y},read from file="foo.dat"];
\end{tikzpicture}
\end{document}

foo.dat

1, 2
3, 4
5, 6

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.