Gnuplot:将数据文件拆分为设置数量的行,并分别绘制每个行

Gnuplot:将数据文件拆分为设置数量的行,并分别绘制每个行,gnuplot,Gnuplot,欢迎大家,我有一个包含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

欢迎大家,我有一个包含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

成功了,谢谢@theozh@SofaScientist很高兴听到,那么请勾选答案处的复选标记,表示问题已回答。