gnuplot: How to plot each line of a data file as Y and incremental X

cartoonist picture cartoonist · Dec 27, 2011 · Viewed 16.7k times · Source

I have a data file containing 30 columns and N rows. Each rows correspond to 30 values of function f(x) for x={1,...,30}. The data file has following pattern:

#<index> f(1) f(2) ... f(30)
1 7.221 5.302 ... -1.031
2 4.527 3.193 ... 0.410
...
N 6.386 1.321 ... -0.386

gnuplot interprets first column as X and the second one as Y. But, what I want is to plot each line in a separated output file without transposing this data file. For example, for the first line, the desired output would be what gnuplot gets with this input file:

# X Y
1 7.221
2 5.302
...
30 -1.031

Answer

cartoonist picture cartoonist · Jan 3, 2012

I found a solution:

plot "data.dat" matrix every 1::1 with linespoint
  • matix indicates data file type by which the input file interpreted as matrix.
  • every 1::1 skip the first column