Search code examples
bashgnuplot

plot only specific columns in gnuplot


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.


Solution

  • 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.