# tikz: plotting a one column file [closed]

I use tikz/pgf to plot plots with data from a file. This works perfectly fine if I have at least to columns in the file that I can choose from. However, I have a rather huge file with just one column. This should represent the y-axis. The x-axis should be just the number of the entry/row/line. I wonder why gnuplot can handle this easily but I have problems getting this run with tikz/pgf. Here is one approach that does not work:

\documentclass{article}

\usepackage{pgf}
\usepackage{tikz}
\usepackage{pgfplots}
\usepackage{pgfplotstable}

\begin{document}

\begin{tikzpicture}
\begin{axis}
\addplot plot file {lala};
\end{axis}
\end{tikzpicture}

\end{document}


And here's another one that does not work:

\documentclass{article}

\usepackage{pgf}
\usepackage{tikz}
\usepackage{pgfplots}
\usepackage{pgfplotstable}

\begin{document}

\begin{tikzpicture}
\begin{axis}
\addplot table[y index=0] {lala};
\end{axis}
\end{tikzpicture}

\end{document}


'lala' looks like this:

10
9
3
2


It should be an easy one, but all the examples I find are with at least two columns.

o

/edit: Sorry, I forgot about the error message:

Runaway argument?
tream@end \ETC.
! Paragraph ended before \pgfplots@addplotimpl@file@parsesingle was complete.
<to be read again>
\par
l.15


/edit2: After Jake's comment, I run the following example:

\documentclass{article}

\usepackage{pgfplots}
\usepackage{pgfplotstable}

\begin{document}

\begin{tikzpicture}
\begin{axis}
\addplot table [x expr=\coordindex,y index=0] {lala.dat};
\end{axis}
\end{tikzpicture}

\end{document}


Unfortunately it gives me the following error message:

! Package pgfkeys Error: I do not know the key '/tikz/x expr' and I am going to
ignore it. Perhaps you misspelled it.


This person has the same error message. It is obviously because of my old texlive (2009) which is installed on my Linux Mint 12 (Ubuntu 11.10). I'll try to install texlive2010.

-

## closed as too localized by percusse, Paul Gaborit, Marco Daniel, Claudio Fiandrino, JakeSep 19 '12 at 7:39

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.If this question can be reworded to fit the rules in the help center, please edit the question.

You should install TeXLive 20 12, not 2010 =) –  Jake Sep 13 '12 at 20:37
Sorry, you're right. I even downloaded it! Thanks for your help! I will see if your solution works when I got this installed. –  Oliver Sep 13 '12 at 20:45

By default, PGFPlots assumes that the data for the x coordinates is in the first column of the file, and the data for the y coordinates is in the second column. If you want to use the row number as the x coordinate, you can use \addplot table [x expr=\coordindex, y index=0]. Note that you'll have to use table instead of file: The latter always uses the first column for the x and the second column for the y coordinates.

\documentclass{article}

\usepackage{pgfplots}
\usepackage{pgfplotstable}

\begin{document}

\begin{tikzpicture}
\begin{axis}
\addplot table [x expr=\coordindex, y index=0] {
10
9
3
2
};
\end{axis}
\end{tikzpicture}

\end{document}

-
Thanks for that fast answer! Unfortunately, it breaks with another error message: ! Package pgfkeys Error: I do not know the key '/tikz/x expr' and I am going to ignore it. Perhaps you misspelled it.. Maybe it was a misunderstanding, lala is the file name and 10, 9, 3, 2 the content of the file ... –  Oliver Sep 13 '12 at 19:51
@Oliver: Sorry, I should have clarified that you'll have to use table instead of file for this. I've edited my answer. Providing the file name or the table data directly doesn't make a difference in this case. –  Jake Sep 13 '12 at 19:56
It does not work anyway. I always get the error message above. Do I need to include something else? –  Oliver Sep 13 '12 at 20:00
@Oliver Try \addplot table [x expr=\coordindex, y index=0] {lala.data}; –  Paul Gaborit Sep 13 '12 at 20:05
@Oliver: Could you edit your question to include an example that gives you the error message? –  Jake Sep 13 '12 at 20:29