How to build a file contains many columns and column header using gnuplot

I have a data file, for example:

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

But I do not know the exact number of columns, but I can get it in a variable with a shell. And I want to build a data file, the first column as the x axis, and the rest as the y axis in one image, and the column heading as the header for the row. For instance:

enter image description here

How to build in gnuplot? Thank you very much

+4
source share
1 answer

Consider this example

colhead.gp

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

colhead.dat

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

To get a parameter from the shell:

 gnuplot -persist -e "n=4" colhead.gp 
+7
source

Source: https://habr.com/ru/post/1490204/


All Articles