Search code examples
gnuplot

Gnuplot looping and divide column by previous column


I have a dataset which I am looping through plotting using the following script:

   do for [i=4:${numcols}:2] { 
      plot '${output}' using 0:i with lp title columnhead 
   }

How can I make it so that I am plotting the (i+1)th column divided by the 78th column, all divided by the ith column?

ie col(i+1)/(col(78) * col(i))


Solution

  • That looks like it ought to work. Are you getting an error? The only problem I see is that "title columhead" is now ambiguous because you have referred to 3 separate columns in the plot. Replace it with "title columnhead(i)" or i+1 or whatever, giving

    do for [i=1:NUMCOLS:2] {
        plot OUTPUT using 0:(column(i+1)/column(78)*column(i)) title columnhead(i+1)
    }