# plot with tikz/pgf from external txt file with one X axis and several Y axis

I am a very beginner of Tikz/pgf. I have searched quite long but didn't found the answer. How could I plot from an external txt or dat file that with one X value and several Y values? For example, the external txt file could be like this,

Many thanks!

It is easy using y index with pgfplots.

\documentclass{article}
\usepackage{pgfplotstable}
x y1 y2 y3 y4
0   3   4  13   14
1   5   6  15   16
2   2   3  12   13
3   4   8  14   18
4   6   9  26   19
5   8   1  18   11
6   10  2  12  12
}\mytable
\usepackage{pgfplots}
\pgfplotsset{compat=1.11}
\begin{document}
\begin{tikzpicture}
\begin{axis}
\addplot table [x index=0, y index=1]{\mytable};
\addplot table [x index=0, y index=2]{\mytable};
\addplot table [x index=0, y index=3]{\mytable};
\addplot table [x index=0, y index=4]{\mytable};
\end{axis}
\end{tikzpicture}
\end{document}


If you have valid column names you can simply use

\addplot table [y=y1]{\mytable};

• Why y index? Columns have pretty legal names. – percusse Jan 27 '15 at 0:41