Search code examples
bashgnuplot

How to perform a simple calculation to with my bash script variables in gnuplot


I have variables M_i and M > M_i. I want to make a splot where one of the columns of my data file is evaluated using these variables...

Something like this:

splot "9.90000000orbs.dat" u 1:2:(10+4*($M-$M_i))

I can't figure out the correct syntax for the last column specification. How do I do it?

Thanks in advance.


Solution

  • Here's a way to achieve this:
    Specify a function to use as the third plot argument.

    x(x) = x
    splot "9.90000000orbs.dat" u 1:2:x(10+4*(M-M_i))
    

    Note, that you have to discard the $ before M and M_i respectively. Now, if (10+4*(M-M_i))=14, the function x(x) will ensure that you plot x(14) which is the 14th column.

    It worked for me using a simple test case and gnuplot 4.6