0

I have a tabla with 4 columns.

I need gnuplot to obtain the MAX and MIN values of the difference between columns 3 and 4 (3-4). I've tried the usual procedure but it doesn't work:

plot 'datafile' using 1:2:(\$3-\$4) with image
max=GPVAL_DATA_Z_MAX
min=GPVAL_DATA_Z_MIN

But it does work if I just use for instance:

plot 'datafile' using 1:(\$3-\$4)
max=GPVAL_DATA_Y_MAX
min=GPVAL_DATA_Y_MIN

Meaning that the problem is with the Z GPVAL variable and the with image option.

I can't use my workaround because it leaves a horrible graph behind my actual graph after I use the plot command again to make the actual plot.

How can I work around this?

5
  • That's odd, and I'll try looking into it, but it seems like you already have a workaround. Plot 1:($3-$4) and get the max and min values you want, then replot using all three dimensions. One question: why do you have the `` character in your script? It isn't necessary.
    – andyras
    May 30, 2012 at 14:18
  • The problem with my workaround is that it produces a nasty plot which is not the plot I want. If I use this workaround then after I make the actual plot, that nasty plot will be seen in the back. What character do you mean?
    – Gabriel
    May 30, 2012 at 15:15
  • I meant the backslash--not sure why it didn't show up. One trick you can use is to set output '\dev\null' (or some other junk file), make the first splot, then change the output to an actual file, and make your plot. That way you won't have the first plot in the background.
    – andyras
    May 30, 2012 at 15:39
  • I just did something very similar and it worked fine: set origin -10,-10. If you put this comment above as an answer, I'll mark it as the right one. Thanks!
    – Gabriel
    May 30, 2012 at 15:41
  • OK, I updated my answer to use that trick.
    – andyras
    May 30, 2012 at 15:44

1 Answer 1

1

The problem comes from using the plot command instead of splot. The plot command only knows about two dimensions. If you try

set terminal postscript enhanced color
set output '/dev/null'
splot 'datafile' using 1:2:($3-$4)
max=GPVAL_DATA_Z_MAX
min=GPVAL_DATA_Z_MIN
set output 'output.eps'
plot 'datafile' using 1:($3-$4) with image

you should be able to get the values you need. Setting output '\dev\null' allows you to get those values without actually plotting the data.

5
  • I only want two dimensions actually. The Z value is used for a color-bar. The real command I'm using is: plot 'datafile' using 1:2:(\$3-\$4) with image
    – Gabriel
    May 30, 2012 at 15:16
  • I've explained the issue a bit better.
    – Gabriel
    May 30, 2012 at 15:21
  • Well I might have spoken too soon. I'm having some weird issues, I'll make another question as a follow-up to this one.
    – Gabriel
    May 30, 2012 at 17:12
  • When I want to get the information about a dataset through a plot command, I use the unknown terminal. set term unknown -- I think this is a little more clean than sending output to /dev/null/ (It'll work on windows too for example). Also note that gnuplot 4.6 has stats command for this purpose : I should really download 4.6 and start playing around with it a bit ;).
    – mgilson
    May 30, 2012 at 17:48
  • Yes, set term unknown is more clean--I expect it would work on all OSes. I didn't know about that option.
    – andyras
    May 30, 2012 at 19:11

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.