Ruby Power

As Ctioga is written in Ruby and is internally letting Ruby take care of most of the computations, you can use your knowledge in Ruby to improve your plots. Let’s suppose for example that you are only interested in the function gathering the maximum value of two of your data columns. You can use the .max method implemented for all ‘Enumerable’ you find in Ruby, for example Arrays:

 ctioga -t 'Everybody likes to go there' \
        -l 'Max value'                    \
        trig.dat@'$1:[$2,$3].max'

Nice image

Sure enough, you can also use the .min method.

What if you would like to put some conditions on plotted points ? You just have to use some ‘if’ statements

 ctioga -t 'First and third quarter' \
        -l 'Conditionnal drawing'    \
        trig.dat@'$2:(if $3*$2 > 0 ; $3 else 0.0/0.0 ; end)'

Nice image

Note the use of 0.0/0.0 to get a NaN which will not be drawn.

If you are curious of the Dvectors defined by Tioga and extensively used by Ctioga, you can also use some of their power to speed up computation or simply writing. For example to sum the squared roots of 3 curves

 ctioga -t 'Square root summation'   \
        -N trig.dat@'$1:sqrt($2##4)' \
        -l 'Sum using Dvectors'      \
        trig.dat@'$1:Dvector[$2,$3,$4].safe_sqrt.sum'

Nice image

You can find many more Dvector’s shortcuts on the dedicated web page, looking for “Dobjects:Dvector” in the central frame:

http://theory.kitp.ucsb.edu/~paxton/tioga_doc/