# how to plot a sequence of numbers (not co-ordinates as such) using pgfplots

I have a data file containing a sequence of numbers, to be plotted against integers starting from 1. So the x co-ordinate is the row number of the data in the file. How to plot this data using pgfplots?

UPDATE1: my data file looks like this

%cmc curve of nist14G21600V0P8T1sumFuse.bin

73.037

75.2963

76.7407

77.8889

79.1111

79.8519

80.3333

80.7407

81.0741

81.4444


UPDATE 2:

When the above data is plotted using the command

\addplot  table [x expr=\coordindex + 1,y index=0]{datafile.txt};


the x axis does not start with 1. It starts with 0. Any suggestions?

-

Based on the new request of @suresh:

pgfplots can read a data file and plot the contents. To use a special column of the data file you can use y index for the y values. The first column has the index 0. For the x axis you can use \coordindex started by 0. To start at 1 you can use \coordindex+1.

\documentclass{article}
\usepackage{amsmath}
\usepackage{pgfplots}
\usepackage{pgfplotstable}
\usepackage{filecontents}
\begin{filecontents*}{datafile.dat}
%cmc curve of nist14G21600V0P8T1sumFuse.bin

73.037

75.2963

76.7407

77.8889

79.1111

79.8519

80.3333

80.7407

81.0741

81.4444
\end{filecontents*}
\begin{document}
\begin{tikzpicture}
\begin{axis}
\addplot +[only marks,] table[x expr=\coordindex+1,y index=0] {datafile.dat};
\end{axis}
\end{tikzpicture}
\end{document}


ORIGINAL

You can use the option x expr=\coordindex.

\documentclass{article}
\usepackage{amsmath}
\usepackage{pgfplots}
\usepackage{pgfplotstable}
\usepackage{filecontents}
\begin{filecontents}{datafile.dat}
Y-Value
2
5
8
1
5
7
6
\end{filecontents}
\begin{document}
\begin{tikzpicture}
\begin{axis}
\addplot +[only marks] table[x expr=\coordindex,y=Y-Value] {datafile.dat};
\end{axis}
\end{tikzpicture}
\end{document}


-
thanks for the reply. But I face some other issues now. First of all my file does not have a column name. What it has is a bunch of lines starting with % character followed by data line by line. Basically I was using gnuplot so far and the file is generated with gnuplot in mind. I tried giving just table[x expr = \coordindex]{datafilename} but it gave me an error message saying that Sorry, the requested column number '1' in table 'datafilename' does not exist!? So what to do now? –  suresh Mar 12 '12 at 20:37
@suresh: Nice information. Please add this information with a small example file to your question. –  Marco Daniel Mar 12 '12 at 20:44
I have just given the sample datafile. I tried adding header=false, but didn't help either. –  suresh Mar 12 '12 at 20:49
@suresh: I edited my answer. –  Marco Daniel Mar 12 '12 at 20:57
Thanks it helped, but two more questions. I get an error message saying that ! Package pgfkeys Error: I do not know the key '/tikz/skip first n' and I am going to ignore it. Perhaps you misspelled it. I checked the log file and found out that the versions are: Package: pgf 2008/01/15 v2.10 (rcs-revision 1.12),pgfplots 2010/07/14 Version 1.4.1. So are you using a newer version? My second question is: cant pgfplots by default ignore lines starting with '%'. I remember to have read somewhere that lines starting with % are ignored. –  suresh Mar 12 '12 at 21:02