Search code examples
matrixplotgnuplot

Gnuplot how can I draw matrix every nth line


I have following data

...
   10800    42.835282    2.0799322    9.6376456     14.69194     15.74205    16.591997    14.208506    17.036752    16.974312    30.759594    318.69734
   10900    59.608134    2.0319971    10.413494    17.136174    18.597465     19.31398     16.78688    19.939459    20.034195    43.809158     470.3118
   11000    71.147383    2.3502536    11.098845    19.525944    21.618026    22.255387    19.446565    22.871378    23.265609    60.717349    559.03537
   11100    70.844437    2.5290753    11.759208    21.795673     24.63466    25.294785    22.079689    25.788459    26.690083    80.472264    513.94945
...

Data have total 600 lines, 12 columns. I want to plot line-wise data for every 50th line, from 3rd column to 12th column. I used plot data matrix (because [i=3:12] was not working as I intended)

data = "data.dat"
plot data matrix every 1::2 w l

This give me the plot what I want (draw 3rd ~ 12th columns of each lines), but draws the curves for all 600 lines. How can I draw every 50th lines in this matrix every 1::2 command, so only 12 curves are shown?

Thanks

ps) I just solved by myself by using sed command like

plot '<sed -n "0~50p" data.dat' matrix every 1::2 w l

Solution

  • To plot every 50th row, you must make use the block values for every:

    plot "data.dat" matrix every :50:2 with lines
    

    That plots every point starting from column 3 in every 50th row.