Credits Overview Plotting Styles Commands Terminals

if

     plot ... if (<expression>)
     splot ... if (<expression>)

For each line of input data the expression in the if filter is evaluated and the line is accepted only if the resulting value is true (non-zero). Any function or variable that would be valid inside a using specifier is also valid in the filter expression, including data columns that are not otherwise used for plotting.

Data lines for which the expression evaluates to false (zero) are treated as if they were not present in the file (see missing). This provides a more readable equivalent to the previously supported method that inserted a logical test inside one of the using specifiers.

Old syntax (still accepted):

     set datafile missing NaN
     plot FOO using (strcol(1) eq "ABC" ? $2 : NaN):3 with linespoints
     plot $DATA using 1:($2 < 999. ? $2 : NaN)

New syntax:

     plot FOO using 2:3 with linespoints if (strcol(1) eq "ABC")
     plot $DATA using 1:2 if ($2 < 999.)

Both the old and new examples select only the lines in input file FOO that have ABC in the first column, and only lines in $DATA where the value in column 2 is less than 999.

This filter is also accepted for splot commands, with the slight difference that when the filter expression returns 0 (false) the point is treated as undefined rather than missing.