Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to plot file contains many columns and column header using gnuplot

Tags:

plot

gnuplot

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

like image 269
user2256235 Avatar asked Mar 24 '23 06:03

user2256235


1 Answers

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
like image 179
slitvinov Avatar answered Apr 25 '23 14:04

slitvinov