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.

I would like to draw a vector field from a data file. I tried to adapt code from Manual for Package pgfplots but this doesn't work

\documentclass{standalone}
\usepackage{pgfplots}

\pgfplotstableread{vector_field.dat}{\loadedtable}

\begin{document}
\begin{tikzpicture}
\begin{axis}[title=Quiver and plot table]
\addplot[blue,quiver={u=\thisrow{u},v=\thisrow{v}},-stealth] table from  \loadedtable;
\end{axis}
\end{tikzpicture}
\end{document}

where data file vector_field.dat is :

x y u v
0 0 1 0
1 1 1 1
2 4 1 4
3 9 1 6
4 16 1 8

During compilation I get for example this error:

! Undefined control sequence.
\pgfk@/data point/quiver/u ->\thisrow
{u}
l.8 ...row{v}},-stealth] table from \loadedtable;
The control sequence at the end of the top line
of your error message was never \def'ed. If you have
misspelled it (e.g., `\hobx'), type `I' and the correct
spelling (e.g., `I\hbox'). Otherwise just continue,
and I'll forget about whatever was undefined.
! Package PGF Math Error: Unknown function `u' (in '{u}').

Does anyone now how to solve it? I would be grateful for any help.

share|improve this question
add comment

1 Answer

I get the error message ! Package PGF Math Error: Unknown function `thisrow_unavailable_load_table_directly'. If I do that, that is, if I use \addplot ... table {vector_field.csv};, the document compiles:

\documentclass{article}
\usepackage{pgfplots}

\begin{filecontents}{vector_field.dat}
x y u v
0 0 1 0
1 1 1 1
2 4 1 4
3 9 1 6
4 16 1 8
\end{filecontents}

\pgfplotstableread{vector_field.dat}{\loadedtable}

\begin{document}
\begin{tikzpicture}
\begin{axis}[title=Quiver and plot table]
\addplot[blue,quiver={u=\thisrow{u},v=\thisrow{v}},-stealth] table \loadedtable;
\end{axis}
\end{tikzpicture}
\end{document}
share|improve this answer
add comment

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.