4

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 Answer 1

7

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
Sign up to request clarification or add additional context in comments.

1 Comment

I think you want "n=4" as the input if you want the for loop to pick up all columns.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.