title: Plotting horizontal lines in gnuplot on an existing graph, using the same coloured lines
body: <p>The starting point is that I have a graph with 4 lines on it. They are the results of my simulation, plotted over an x-axis of iteration, at 4 different locations.  I also have experimental values at each of those locations.  I want to plot those 4 experimental values as horizontal lines on the same graph.  I would also like the line colours of the simulation and experiment results at each location to be the same.</p>
  
  <p>With @Tom's help, below, I have got the following script to do this:</p>
  
  <pre><code>unset bars
  max = 1e6
  set xrange[7000:24000]
  set yrange[-0.5:1.5]
  plot for [i=2:5] 'sim' using 1:(column(i)) ls i, \
  for [i=1:4] 'expt' using (1):1:(max) every ::(i-1)::(i-1) with xerror ls i ps 0
  </code></pre>
  
  <p>The problem is that I want the values in <code>xrange[x_min:x_max]</code> and <code>yrange[y_min:y_max]</code> to be taken from <code>sim</code> and <code>expt</code> as follows:</p>
  
  <pre><code>x_min = min(sim[:1])   # where min(sim[:1]) means "min value in file 'sim' col 1"
  x_max = max(sim[:1])
  y_min = min(sim[:2],sim[:3],sim[:4],sim[:5],expt[:1])
  y_max = max(sim[:2],sim[:3],sim[:4],sim[:5],expt[:1])
  </code></pre>
  
  <p>My OS is Scientific Linux: Release 6.3, Kernel Linux 2.6.32-358.2.1.el6.x86_64, GNOME 2.28.2</p>
  
  <p><code>sim</code> and <code>expt</code> are .txt files</p>
  
  <p>A representative sample of <code>sim</code> is:</p>
  
  <pre><code>7520    0.282511    0.0756715   -0.222863   -0.0898819
  7521    0.315944    0.201687    -0.321723   -0.106345
  7522    0.230956    0.102217    -0.34196    -0.061009
  7523    1.460043    -0.00118292 -0.045077   0.673926
  </code></pre>
  
  <p>A representative sample of <code>expt</code> is:</p>
  
  <pre><code>1.112
  0.123
  -0.45
  0.862
  </code></pre>
  
  <p>Thank you for your help.</p>