title: gnuplot: max and min values in a range
body: <p>I'm plotting some data with a different X range and I would like to change yrange according to the maximum and minimum value of the data in the current X range. When I use GPVAL_Y_MAX and GPVAL_Y_MIN, these values correspond to the maximum and minimum of the whole data, not just the data in the range.</p>
  
  <p>For example, I have the following data:</p>
  
  <pre><code>1 3
  2 5
  3 8
  4 20
  5 30
  </code></pre>
  
  <p>I use the following script:</p>
  
  <pre><code>plot 'data.txt' u 1:2;
  set xrange [1:3];
  replot
  set xrange [1:5];
  replot
  </code></pre>
  
  <p>In the first plot I would like to set yrange in [3:8], but in the second plot the yrange sholud be [3:30]. If I use something like</p>
  
  <pre><code>set yrange [GPVAL_Y_MIN:GPVAL_Y_MAX]
  </code></pre>
  
  <p>GPVAL_Y_MIN and GPVAL_Y_MAX have the same value independently of the xrange.</p>
  
  <p>Any solution?</p>