26

I have column-formatted data and I want to make a splot of the logarithm of the 5th column versus the first two columns. I have tried:

set pm3d map
splot "thing.file" u 1:2:log($5)

But I get the error

undefined value

How can I get gnuplot to plot a function of one of the columns of data?

3 Answers 3

37

This works:

splot "thing.file" u 1:2:(log($5)) 

In general, if a term is defined by a function of a column in a data file rather than the column itself, there need to be parentheses around that term.

Sign up to request clarification or add additional context in comments.

Comments

8

To extend the solution, you can use multiple columns if your function requires multiple inputs: example:

plot "file" using 1:(x=$2, y=$3, f(x,y)) 

also works.

1 Comment

A note to noobs like me. In gnu plot, while writing a function, one doesn't write x^y but x**y. I was making this mistake.
-8

Taken from gnuplot's own FAQ , "Gnuplot has been and is a plotting program,not a data processing or mathematical program suite. Therefore gnuplot can't do that.".

You can run your data file through Octave or Matlab to generate the log files before plotting.

3 Comments

Figured it out: If I enter: splot "thing.file" u 1:2:(log($5)) it runs the function on that column. In general, there need to be parentheses around an expression involving functions of a column, I think.
@Dan Why not make that an answer?
I don't have enough reputation to answer my own question until 8 hours after I post it.

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.