archenoo
archenoo

Reputation: 149

Gnuplot: How to get the coordination (x,y,z) of the point whose z value is the max?

The data file has 3 columns, corresponding to (x,y,z), and the style is set to be able to draw 3D surface.

I find that the command GPVAL_DATA_Z_MAX can give the max z value, and I want to find the left x,y of the max point, although there maybe more than one point owning the max z.

So, I use GPVAL_DATA_X_MAX, GPVAL_DATA_Y_MAX, but I get the wrong position, because the three column are irrelavent, these two commands function like GPVAL_DATA_Z_MAX. So how can I find the (x,y,z) of the point whose z value is the max?

Upvotes: 0

Views: 1120

Answers (1)

psibar
psibar

Reputation: 2000

You can do another (temporary) plot, which displays only the point where z is max.

I do it like this:

plot "Datafile" using ($3==GPVAL_DATA_Z_MAX?$1:NaN):($3==GPVAL_DATA_Z_MAX?$2:NaN):3

This will only plot the point(s) where z=GPVAL_DATA_Z_MAX.

After this plot GPVAL_DATA_X_MAX and GPVAL_DATA_Y_MAX will have the values which belong to ().

Upvotes: 1

Related Questions