3
votes

I have a csv file as show below and i want to plot S(on x axis) and B(axis).How do i generate a plot of lines with gnuplot.

    Test_Image,Original_Size
    red-room.png,918394
    Q,S,B,S,C,R
    0,1021763,0.121086,0.00001459,-11.26,-222.18
    1,1061763,0.125086,0.00001459,-11.26,-222.18
    2,1051763,0.121086,0.00001459,-11.26,-222.18
    3,1041763,0.121086,0.00001459,-11.26,-222.18
    4,986461,0.151573,0.00003318,-7.63,-211.67
    5,955766,0.160869,0.00005782,-4.07,-201.37

Basically i need to a way to tell gnuplot to ignore the first 3 rows and plot the 2rd and 3rd column.

2

2 Answers

7
votes

You need to tell gnuplot that fields are delimited by commas and that it should plot columns 2 and 3:

set datafile separator comma
plot "data.csv" using 2:3 w lp

Gnuplot will ignore the first three lines automatically.

2
votes

You can modify the data as it is read in (without affecting your input file) like this:

plot 'awk -F, "NR>3{print $2,$3}" data.csv |' using ...

That says to print fields 2 and 3 of lines where line number is greater than 3 of your input file data.csv.

You can experiment with the awk command stand-alone in the Terminal to test it outside of gnuplot:

awk -F, 'NR>3{print $2, $3}' data.csv