Just for the records, there is no need to use gawk
or other external tools, you can simply do it with gnuplot only and hence platform-independently.
For gnuplot<5.0.7 you have to use a workaround for connecting the filtered data points with lines.
Script: (works for gnuplot>=5.0.7, Aug 2017)
### filter data
reset session
$Data <<EOD
# plotnum xaxis yaxis
1 2 1
2 3 2
1 3 3
2 5 4
1 4 4
2 6 2
EOD
set datafile missing NaN
myFilter(colD,colF,valF) = column(colF) == valF ? column(colD) : NaN
plot for [i=1:2] $Data u (myFilter(2,1,i)):3 w lp pt 7 ti sprintf("Dataset %d",i)
### end of script
Result:

Addition:
The above script checks if the first column is 1
or 2
, which is the general case and covers arbitrary sequences of 1
and 2
. However, if you can be sure that column 1 starts with 1
and is strictly alternating with 2
, then you can do the following which actually uses every
and is much simpler.
Data: SO39154659.dat
# plotnum xaxis yaxis
1 2 1
2 3 2
1 3 3
2 5 4
1 4 4
2 6 2
Script: (works at least with gnuplot>=4.4.0, March 2010)
### plot alternating data
reset
FILE = "SO39154659.dat"
plot for [i=1:2] FILE u 2:3 every 2::i-1 w lp pt 7 ti sprintf("Dataset %d",i)
### end of script
Result: (same as graph above)