GNUPLOT complex numbers in data file


I have a file with two columns, the first containing purely real numbers and the second containing complex number in a form the GNUPLOT will accept, {a,b} (which is GNUPLOT's equivalent to a + bi). I would like to plot the first column with the absolute value of the second so I tried this:

plot 'data.dat' using 1:abs(2)

This, however, doesn't seem to work. Does anyone know how I can tell GNUPLOT to perform an operation on the data in the dat file before plotting it?

Best Solution

It would save yourself a lot of effort and store your data in three columns, where the second and third denote real and imaginary part.

You can achieve what you are looking for by:

plot "data" using 1:(sqrt($2**2+$3**2))
Related Question