Gnuplot:将数据文件拆分为设定的行数并分别绘制每组

Gnuplot: Split data file into set number of rows and plot each set separately

大家好,我有一个包含n*16行的数据文件。我需要将它分成 n 组 16 行,即从 1 到 16、17 到 32 和 32 到 48 等。输出将生成 n 个文件,每个文件有 16 行数据。示例代码如下。

set terminal png
set output 'Test1.png'
set xr [0.0:8.0]
set style line 1 lt 1 lc rgb "blue" lw 1 pt 11   
#        MULTIPLE GRAPH for type 1 or type 2 solutions
plot  'test1.dat' u 3:8 every ::0::16  with  lines ls 1 title "Number Density"
EOF  ``` 

尝试这样的事情:

### plot blocks à 16 rows into 16 files
reset session
set terminal png

FILE = 'Test1.dat'

myFile(n) = sprintf("Test%02d-%02d.png",(n-1)*16+1,n*16)

do for [i=1:16] {
    set output myFile(i)
    plot FILE u 3:8 every ::(i-1)*16::i*16-1 w l
}
set output
### end of code