是否可以在 gnuplot 中每十行画一行?

Is it possible to draw one line per ten lines in gnuplot?

我有如下数据文件:

#X1 y1 x2 y2 Number
123 567 798 900 1
788 900 87  89 2
....

然后我使用以下命令绘制图表

plot '~/Desktop/pointcolor.txt' using 1:2:(-):(-):5 with vectors palette nohead notitle

这是结果。

正如你在上图中看到的那样,结果被压缩了,所以我想在数据文件中每十行绘制一条具有相同数字的行。

编辑 1:

我试试@ewcz的解决方案,如下:

stat="0 0 0 0 0 0 0" # How should I define array as [gnuplot][2] didn't support it? 
plot "< awk '{if(( (stat[]++)%10==0 )) print}'~/Desktop/pointt.txt" using 1:2:(-):(-):5 with vectors palette nohead notitle

但是我得到这个错误:

gnuplot> load "gnuplot.cmd"
awk: line 1: syntax error at or near 

gnuplot> plot "< awk '{if(( (stat[]++)%10==0 )) print}'~/Desktop/pointcolor.txt" using 1:2:(-):(-):5 with vectors palette nohead notitle
                                                                                                                                       ^
         "gnuplot.cmd", line 6: warning: Skipping data file with no valid points

gnuplot> plot "< awk '{if(( (stat[]++)%10==0 )) print}'~/Desktop/pointcolor.txt" using 1:2:(-):(-):5 with vectors palette nohead notitle
                                                                                                                                              ^
         "gnuplot.cmd", line 6: x range is invalid

编辑2:

解决方法:

 plot "< awk '{if((stat[]++)%10==0) print}' ~/Desktop/pointt.txt" using 1:2:(-):(-):5 with vectors palette nohead notitle

为了实现这一点,必须(很可能)对输入进行某种预处理。幸运的是,Gnuplot 允许以直接的方式绘制命令的结果。在您的情况下,可以将 plot 命令修改为:

plot "< gawk '{if((stat[]++)%10==0) print;}' ~/Desktop/pointcolor.txt" ...

这里,行的id(基于第五列)存储在数组stat中。如果此 id 可被 10 整除,则打印该行并绘制(即丢弃其他输入行)。