3

I want to plot the inverse of the numbers in a number of columns against the first column:

plot for [i=1:30] 'file' using 1:(1/i) w lp

which results in all the y values to be zero. It works when I remove the for loop and just pick a column to plot: p 'file' u 1:(1/$4). What am I doing incorrectly?

1 Answer 1

4

Inside the parentheses the i is only an integer number, and you get always zero. To access the value of a column inside an expression, use column(i):

plot for [i=1:30] 'file' using 1:(1/column(i)) w lp

The $4 is a shortcut for column(4). To understand this better, have a look at

i = 2
plot 'file' u 1:i, '' u 1:(i)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.