• Variable for data column number?

    From andreas.buchgraitz@gmail.com@21:1/5 to All on Thu Jan 30 08:53:02 2020
    tirsdag den 29. april 2008 kl. 13.33.31 UTC+2 skrev Juergen Wieferink:
    Ingo Thies wrote:
    c1=1;c2=2
    plot 'file' using c1:c2

    But is it also possible to use variables for column numbers as a
    function argument? "$c1" or similar don't work. For now, I can only do
    this by replacing the column specifier in all the lines by
    search&replace, but a global switch would be much more convenient.

    This could be done using macros "help macro", but the clean way is
    via the column() function (help column) [untested]:

    c1=1;c2=2
    plot 'file' using (column(c1)):(column(c2))


    Juergen

    Thanks, This works amazing if one wants to do math on each entry in a column, but directly in a bash script, for example subtracting some number from every entry:

    #!/bin/bash

    gnuplot <<-EOF

    set terminal pdf
    set output "test.pdf"
    plot "data.dat" u 1:(column(2)-2.63E-02) with lines

    EOF

    evince test.pdf

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)