As mentioned already in the other answers, the most efficient way is certainly to transpose the data and use simple standard gnuplot plotting commands.
If you want a platform-independent gnuplot-only solution you could do the following:
If all rows have the same number of columns you can plot the data using the option matrix
(check help matrix
). There are a few examples here on SO. However, here, the additional difficulty is to get the xticlabels and the legend as well.
I tried a few script variations, but the one below was the only one I found which seems to work unchanged for both gnuplot4.6.0 (March, 2012) and gnuplot5.5.0 (July 2021).
I don't want to say the solution is beautiful, but it works with gnuplot-only.
Data: SO22438313.dat
(taken from Thor's answer)
name; n0; n1; n2; n3; n4
Benj; 1; 3; 2; 5; 3
Silv; 6; 1; 2; 3; 4
Steffi; 3; 2; 2; 4; 2
Carl; 2; 4; 5; 3; 2
Script: (works for gnuplot>=4.6.0, March 2012)
### plotting rows with xticlabels and legend
reset
FILE = "SO22438318.dat"
set datafile separator ';'
set yrange[0:]
set key noautotitle
# set colorsequence classic # optional for gnuplot>=5.0
myTitles = ''
plot FILE matrix u (c=$1):3:(r=$2) every ::1:1 w l lw 2 lc var, \
for [i=1:c]'' u (i):(i==1?myTitles=myTitles.' '.strcol(1):0,NaN): \
xtic($0==0?xt=strcol(i+1):xt) w l lw 2, \
for [i=1:r] '+' u 1:(NaN) every ::0::0 w l lc i lw 2 ti word(myTitles,i+1)
### end of script
Result:
