On Sunday, 15 March 2015 02:54:48 PM pl...@pi... wrote:
> Hi,
>
> I seem to have an oddity in putting a conditional in the using clause in
> v5.0
>
>
> tail longest.dat
>
> 171 3342.447
> 172 3371.391
> 173 3400.336
> 174 3465.342
> 175 3458.227
> 176 3324.896
> 177 3389.902
> 178 3400.818
> 179 3429.764
> 180 3476.738
>
>
> G N U P L O T
> Version 5.0 patchlevel alpha last modified 2014-05-10
>
>
>
>
> gnuplot> plot "longest.dat" using (($1/2*2==$1)?NaN:$1):2
>
> x range is invalid
>
>
> I'm trying to plot for the even values in col 1.
> if I do : using (($1/2*2==$1)?$1:NaN):2 it plots every point
> and using (($1/2*2==$1)?NaN:$1):2 complains that it has an empty x
> range ( ie using is always returning NaN.
That is because $1/2*2 always equals $1.
You are probably thinking that your column 1 values are integers
and therefore $1/2 will be truncated to an integer also, but
that is not the case. Data values are always read in as (double).
Try
plot "longest.dat" using ((int($1)/2*2==$1)?NaN:$1):2
or maybe
plot "longest.dat" using ((int($1)&01 == 01) ? $1 : NaN):2
>
> The syntax of my using clause seem right if I test it in a print:
>
> gnuplot> i=179;print (i/2*2==i)?i:NaN
> NaN
> gnuplot> i=178;print (i/2*2==i)?i:NaN
> 178
>
> I know I could do this using "every" with that sample data but this is
> about the syntax not giving expected result.
>
> Peter.
|