Hello Shaun, Shaun Morgan wrote: > A quick question: is it possible to read coordinates from a file and `pipe' > them in a pgfplots command?. > For example, if I want to define a set of nodes based on coordinates in a > file. Assume the file is: > x1 y1 name_node_1 > x2 y2 name_node_2 > ... > > so pgfplots would read one line at a time and define the corresponding node.
Yes, that is possible using the advanced scatter plot interface. The idea is to a) use the "scatter" key to activate scattered data processing, b) configure the "scatter/@pre marker code" and "scatter/@post marker code" keys. Here is a related example: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \documentclass[10pt]{article} \usepackage{pgfplots} \begin{document} First solution: uses table input with a ``name'' column (as in your request): \begin{tikzpicture} \begin{axis} \addplot+[% the '+' maintains the default color (blue) scatter, %mark=*, %only marks, scatter src=explicit symbolic,% to avoid numerical processing of the "meta=name" column scatter/@pre marker code/.code={% % define the named coordinate. At this time, % \pgfplotspointmeta contains the value of the "scatter % src", which is provided using "meta=name" below \coordinate (\pgfplotspointmeta) at (0pt,0pt); }, scatter/@post marker code/.code={}, ] table[meta=name] {% meta=name means: use the "name" col as "point meta"(="scatter src") x y name 0 0 node1 1 1 node2 2 2 node3 }; \end{axis} \draw (node2) circle (5pt); \end{tikzpicture} Automatically assign named nodes to each input coord using \verb|\coordindex|: \begin{tikzpicture} \begin{axis} \addplot+[ scatter, %mark=*, %only marks, scatter/@pre marker code/.code={% % just use \coordinate, no need to provide an extra % column: \coordinate (node_no_\coordindex) at (0pt,0pt); }, scatter/@post marker code/.code={}, ] table { x y 0 0 1 1 2 2 }; \end{axis} \draw (node_no_0) circle (5pt); \end{tikzpicture} \end{document} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% I think this is what you asked for (please correct me in case I misunderstood it). Details for the procedure can be found in the manual, section scatter plots. Best regards Christian -- Christian Feuersaenger Institut fuer Numerische Simulation Rheinische Friedrich-Wilhelms Universitaet Bonn Wegelerstrasse 6 D-53115 Bonn Germany Tel: +49 228 733430 URL: http://wissrech.ins.uni-bonn.de/people/feuersaenger.html ------------------------------------------------------------------------------ This SF.net Dev2Dev email is sponsored by: Show off your parallel programming skills. Enter the Intel(R) Threading Challenge 2010. http://p.sf.net/sfu/intel-thread-sfd _______________________________________________ Pgfplots-features mailing list Pgfplots-features@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/pgfplots-features