I have data file like following:
#X1 y1 x2 y2 Number
123 567 798 900 1
788 900 87 89 2
....
and I draw my graph using following command
plot '~/Desktop/pointcolor.txt' using 1:2:($3-$1):($4-$2):5 with vectors palette nohead notitle
here is the result.
As you can see in above image, the result is to compressed, so I want to draw one line per ten lines which have same Number in data file.
Edit1:
I try @ewcz solution, as follow:
stat="0 0 0 0 0 0 0" # How should I define array as [gnuplot][2] didn't support it?
plot "< awk '{if(( (stat[$5]++)%10==0 )) print}'~/Desktop/pointt.txt" using 1:2:($3-$1):($4-$2):5 with vectors palette nohead notitle
but I get this error:
gnuplot> load "gnuplot.cmd"
awk: line 1: syntax error at or near
gnuplot> plot "< awk '{if(( (stat[$5]++)%10==0 )) print}'~/Desktop/pointcolor.txt" using 1:2:($3-$1):($4-$2):5 with vectors palette nohead notitle
^
"gnuplot.cmd", line 6: warning: Skipping data file with no valid points
gnuplot> plot "< awk '{if(( (stat[$5]++)%10==0 )) print}'~/Desktop/pointcolor.txt" using 1:2:($3-$1):($4-$2):5 with vectors palette nohead notitle
^
"gnuplot.cmd", line 6: x range is invalid
Edit2:
The solution:
plot "< awk '{if((stat[$5]++)%10==0) print}' ~/Desktop/pointt.txt" using 1:2:($3-$1):($4-$2):5 with vectors palette nohead notitle
In order to achieve this, one has to use (most likely) some kind of preprocessing of the input. Fortunately, Gnuplot allows to plot a result of a command in a straightforward way. In your case, one could modify the plot command as:
plot "< gawk '{if((stat[$5]++)%10==0) print;}' ~/Desktop/pointcolor.txt" ...
Here, the id of the row (based on the fifth column) is stored in an array stat
. If this id is divisible by 10
, the row is printed and thus consequently plotted (i.e., other input rows are discarded).