title: Gnuplot find local maximum of 3D data
body: <p>I have a problem in gnuplot...</p>
  
  <p>I am making an splot from my data points which are discrete "lines" (see attached pic) among y values of 1,1/2,1/3 etc...
  At every discrete "line" I would like to get the maximum Z value and its X and Y coordinates, and highlight them, or maybe fitting a function on them etc...</p>
  
  <p>Here is my code:</p>
  
  <pre><code>set title "1/m vs mutation rate"
  #set term pdfcairo size 6,4
  set term x11
  
  set xlabel "Mutation rate"
  set ylabel "1/m"
  
  set xrange[0.0001:0.05]
  set yrange[1.0/30:1]
  unset log x
  
  set cbrange[0:0.35]
  set zrange[0:1]
  set palette defined ( 0 "green", 1 "blue", 2 "red") 
  
  #set view 78,348,1,1
  set view map
  
  set output "muemmeres500map.pdf"
  
  splot 'muemmeres500.txt' u 1:2:3  with points pt 5 ps 1 palette, "muemmeres500.txt" every 30 using ($3==GPVAL_DATA_Z_MAX?$1:NaN):($3==GPVAL_DATA_Z_MAX?$2:NaN):3 title "max1" lc rgb'black' lw 4, "muemmeres500.txt" every 30::2 using ($3==GPVAL_DATA_Z_MAX?$1:NaN):($3==GPVAL_DATA_Z_MAX?$2:NaN):3 title "max2" lc rgb'black' lw 4, "muemmeres500.txt" every 30::3 using ($3==GPVAL_DATA_Z_MAX?$1:NaN):($3==GPVAL_DATA_Z_MAX?$2:NaN):3 title "max3" lc rgb'black' lw 4, "muemmeres500.txt" every 30::4 using ($3==GPVAL_DATA_Z_MAX?$1:NaN):($3==GPVAL_DATA_Z_MAX?$2:NaN):3 title "max4" lc rgb'black' lw 4, "muemmeres500.txt" every 30::5 using ($3==GPVAL_DATA_Z_MAX?$1:NaN):($3==GPVAL_DATA_Z_MAX?$2:NaN):3 title "max5" lc rgb'black' lw 4
  
  unset output
  </code></pre>
  
  <p>And here is the data file: <a href="http://pastebin.com/umqGWtyy" rel="nofollow noreferrer">http://pastebin.com/umqGWtyy</a></p>
  
  <p>As you can see in the picture, the "lines" data points correspond to each line in the datafile, so for instance the data points starting with the first then every 30 correspond to the "line" which has a y value 1, then from the second line every 30 corresponds to the "line" which y value is 1/2 etc...  </p>
  
  <p>Therefore I wanted to get the maximum Z value from just those data...</p>
  
  <p>I tried sed as well, but I failed...</p>
  
  <p>So my problem is, that it can just find the global maxima and not the other local ones...:( pls help me:)</p>
  
  <p>Here is the picture: <a href="https://i.stack.imgur.com/QdLoz.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/QdLoz.png" alt="enter image description here"></a></p>
  
  <p>I have no idea... hope it is understandable and sorry for my english...:)</p>