4
votes

I have some data file like this:

Id a1 a2 a3
1  1  2  3 
2  2  3  4 
3  2  3  4 

But I don't know the exact number of column, but I can get it into variable with shell. And I want to plot the data file, the first column as the x-axis and the others as the y-axis in one picture and the column header as the title for line.like this:

enter image description here

How to plot in gnuplot? Many thanks

1

1 Answers

7
votes

Consider this example

colhead.gp:

plot for [i=2:n+1] 'colhead.dat' u 1:i w lp title columnheader(i)

colhead.dat:

Id a1 a2 a3
1  1  2  3
2  2  3  4
3  2  3  4

To get parameter from the shell:

gnuplot -persist -e "n=4" colhead.gp