title: gnuplot replot not plotting
body: <p>The short version:</p>
  
  <p>gnuplot's "replot" command is not seeming to plot anything.  Only the original plot ("plot ...") is displayed in the output.</p>
  
  <p>The long version:</p>
  
  <p>I have a shell script cycling through a database of files, some of which need to be plotted in the same output image, some don't.  My approach currently is to have the shell script write a gnuplot script ... something along these lines:</p>
  
  <p>directory of input files, "data"</p>
  
  <pre><code>1_1.csv
  1_2.csv
  1_3.csv
  1_4.csv
  2_1.csv
  ...
  x_y.csv
  </code></pre>
  
  <p>shell.sh</p>
  
  <pre><code>for f in data/*.csv
  do
      gpFile=scripts/gp_x.gp      # x from input filename
      out=out_x.png               # x from input filename
      if [ ! -e "$gpFile" ]; then       # if gnuplot script does not exist
          cat &lt;&lt;-EOF &gt;$gpFile           # create new file called gp_x.gp
          set datafile separator ","
          set term png size 1024,768
          set autoscale fix
          set output $out
          plot "$f" using 1:2 with lines
          EOF
      else                              # file does exist
          cat &lt;&lt;-EOF &gt;&gt;$gpFile          # append file with more text
          replot "$f" using 1:2 with lines
          EOF
      fi
  done
  
  for s in scripts/*.gp  # cycle through all scripts just generated
      gnuplot $s         # run gnuplot scripts
  done
  </code></pre>
  
  <p>So that shell script generates a number of gnuplot scripts, one of which would look like this:</p>
  
  <p>gp_x.gp</p>
  
  <pre><code>set datafile separator ","
  set term png size 1024,768
  set autoscale fix
  set output out_x.png
  plot "x_1.csv" using 1:2 with lines
  replot "x_2.csv" using 1:2 with lines
  replot "x_3.csv" using 1:2 with lines
  replot "x_4.csv" using 1:2 with lines
  </code></pre>
  
  <p>This results in only plotting the first "plot" command, and none of the "replot" commands are accomplished (also, no errors are thrown).  If I were to replace it with something like...</p>
  
  <pre><code>plot "x_1.csv" using 1:2 with lines, \
       "x_2.csv" using 1:2 with lines, \
       "x_3.csv" using 1:2 with lines, \
       "x_4.csv" using 1:2 with lines
  </code></pre>
  
  <p>It works fine.  However, due to some complications in my actual program (this is extremely simplified), it's not really feasible to simply concatenate an extra line like that without the risk of breaking the script (e.g. having arguments with no command).  And either way, I'd like to know why "replot" doesn't seem to work this way (or, more likely, what I'm doing wrong).  Thanks!</p>