0
votes

I have a .csv-file that contains only numeric Values. I want to plot each row as a seperate Plot and use the Values on the y-Axis versus the position of the Value as x-Value. I.e.:

10,2,5,6 9,7,8,6

Any way to do this without externally rearranging the data?

3

3 Answers

0
votes

Here is a very obscure set of commands that does what you ask. I hesitate to recommend it because it is non-obvious to the point of being obfuscated and it is fragile with respect to empty fields or missing data. Requires gnuplot version 5.

# Specify that this is a *.csv file
set datafile separator ","
# This command will plot value as a function of column for row n
plot 'rowdata' matrix using 1:0 every :::n::n with lp
# This command will do the same for each row in the file
plot for [col=1:*] 'rowdata' matrix using 1:0 every :::col::col with lp
0
votes

From what I have seen, gnuplot is made to plot a file column by column. So you probably need to rearrange your data. You might have a look into this topic: how plot per rows in gnuplot

0
votes

For those who are interested, this are the two scripts I ended up with:

animate series of plots using gnuplot (stops at beginning and end):

unset key
set datafile separator ","
stats "radii.csv" every ::1::1 using (time = $203) name "R" nooutput 
set title sprintf("Time = %d",time)
stats "measureUnbound.csv" matrix every :::0:201:0 name "mU" nooutput
ubMin = 1.*mU_max
set yrange [0:40]
pl "radii.csv" matrix u 1:0 every :::1:201:1 w l \
,"radii.csv" matrix u 1:0 every :::0:201:0 w l \
,"measureUnbound.csv" matrix u 1:($3/ubMin*19.5) every :::0:201:0 w i
pause -1
do for [col=1:19000] { \
unset yrange
stats "radii.csv" every ::(col + 1)::(col + 1) using (time = $203) name "R" nooutput 
set title sprintf("Time = %d",time)
stats "measureUnbound.csv" matrix every :::col:201:col name "mU" nooutput
ubMin = 1.*mU_max
set yrange [0:40]
pl "radii.csv" matrix u 1:0 every :::(col + 1):201:(col + 1) w l \
,"radii.csv" matrix u 1:0 every :::0:201:0 w l \
,"measureUnbound.csv" matrix u 1:($3/ubMin*19.5) every :::col:201:col w i
pause 0.1 
}
pause -1

create animated gif:

set term gif animate
set output "radii.gif"
unset key
set datafile separator ","
do for [col=0:19000] { \
unset yrange
stats "radii.csv" every ::(col + 1)::(col + 1) using (time = $203) name "R" nooutput 
set title sprintf("Time = %d",time)
stats "measureUnbound.csv" matrix every :::col:201:col name "mU" nooutput
ubMin = 1.*mU_max
set yrange [0:40]
pl "radii.csv" matrix u 1:0 every :::(col + 1):201:(col + 1) w l \
,"radii.csv" matrix u 1:0 every :::0:201:0 w l \
,"measureUnbound.csv" matrix u 1:($3/ubMin*19.5) every :::col:201:col w i
}
set output

Thanks for your help !

Resulting gif