4

I was trying to implement this method (How to import ASCII coordinates to TikZ) to import coordinates and draw them, but I am having this problem

Undefined control sequence \end{tikzpicture}
Extra }, or forgotten \endgroup \end{tikzpicture}
Extra \endgroup \end{tikzpicture}
Extra \endgroup \end{tikzpicture}
Too many }'s \end{tikzpicture}
Extra \endgroup \end{tikzpicture}
\begin{document} ended by \end{tikzpicture}. \end{tikzpicture}
Extra \endgroup \end{tikzpicture}
Too many }'s \end{tikzpicture}
Extra \fi \end{tikzpicture}

My code is simply

\documentclass{book}
\usepackage{tikz}
%Defining loops for tikz
\def\myloop#1#2#3\repeat{\def\filenm{#2}\def\body{#1#2#3}\iterate}

\def\iterate{\body\ifeof\filenm\let\next\relax\else\let\next\iterate\fi\next}

\usepackage{pgfplots}
\usetikzlibrary{shapes,arrows, calc}
\usepgfplotslibrary{external}
\tikzexternalize[prefix=tikz/]
\pgfplotsset{compat=1.9}

\begin{document}

\newread\bar
\openin\bar=borrar.tex

\begin{tikzpicture}
   \myloop\read\bar to\res\shade[ball color=blue]\res;\repeat
   \end{tikzpicture}
\end{document}

It works whenever I do not include the package pgfplots, but I need this package for some plots. Is there any other way to make it work? Thanks in advance.

Edit:

sorry I forgot to include this. File borrar.tex is just the coordinates for two lines

(0.000000,0.000000) -- (0.000000,2.000000) 
(0.000000,0.000000) -- (2.000000,2.000000) 

Error in the logfile

\bar=\read2
! Undefined control sequence.
\endtikzpicture ...r@layerlist@globally \endscope 
                                              \let \pgf@baseline =\pgf@s...
l.17 \end{tikzpicture}
7
  • Welcome to TeX.SX! Instead of the shortened error messages, please report what's in the log file, which is usually more informative. For instance the first error message is about \endscope. Another thing: we don't have borrar.tex and can't guess its contents.
    – egreg
    Nov 23, 2013 at 22:03
  • Thanks for your comment! Should I include the entire log file? It is pretty long.
    – balborian
    Nov 23, 2013 at 22:14
  • No, that should be sufficient.
    – egreg
    Nov 23, 2013 at 22:15
  • If you want to read the coordinates line by line from the file you need to use \readline instead of \read. Nov 24, 2013 at 10:31
  • 3
    I'm voting to close this question as off-topic because with PGFPlots v1.14 the given example compiles without any error message (when not using the external library, which wasn't explicitly mentioned in the question). Nov 10, 2016 at 21:31

0

Browse other questions tagged .