[Tex/LaTex] Generating Plot in Tikz from Text File


I am trying to learn how to generate a plot given coordinates specificied in a text file, for example, the latex code in:


refers to the text file:


but I'm not quite sure how to get this working on my own latex environment, it doesn't seem to read in the coordinates from the text file. Is it a directory issue or do I need to add something to the code?

Best Answer

Here is a PGFPLOTS solution:

enter image description here

The files fig1.tex, obstacle1d-0.table and obstacle1d-1.table are in the same folder.


    xmin=-1.6, xmax=1.6,
    ymin=-0.6, ymax=1.2,
    axis lines=center,
    axis equal image,
    \addplot[smooth] table {obstacle1d-0.table}
        node[right] {$g(x)$};
    \addplot[very thick,color=red] table {obstacle1d-1.table}
        node[above right] {$v(x)$};