gnuplot

Multiply data in each column by a number in the plot for loop


Gnuplot newbie here, sorry if someone has asked this before, but I got no luck finding anything related to this anywhere, maybe this is too simple, and nobody is asking. Found this somewhat similar but not associated with loop.

So I have some data in .csv file and I wanted to plot Column 2 to 6 as Y, separately, but using the same Column 1 as X. [Note: I have it as Y:X purposely as I want Y data on X-axis and X data on Y-axis.] I am able to do this but when I introduce a factor of 1000 to all the Y values for every column from 2 to 6, I got an error saying "Column number or datablock line expected". Does anyone know how I can factor the all the Y values in Column 2 to 6 using plot for loop?

plot for [i=2:6] 'PFC03(SG#1-#11).csv' u ($i*1000):1 w l t "SG #".(i-1)

Trying to multiply a constant number to all the Y values while using plot for loop.


Solution

  • You've been close, but $i for addressing a variable column number does not work. $1, $2, etc. is a shortcut for column(1), column(2), etc., and column(i) will work if the data has at least i columns. Check help column and help using examples.

    I guess you've been looking for:

    plot for [i=2:6] 'PFC03(SG#1-#11).csv' u (column(i)*1000):1 w l t "SG #".(i-1)