title: Gnuplot and C "x range is invalid"
body: <p>I'm trying to generate a data file and to plot it with Gnuplot. The problem is when I keep my Nstep lower than 348 I get the error</p>
  
  <blockquote>
  <pre><code>line 0: warning: Skipping data file with no valid points
  
  plot 'plot.txt' using 1:2 with lines
                                      ^
  line 0: x range is invalid
  </code></pre>
  </blockquote>
  
  <p>But I keep the <code>Nstep</code> higher than 348 everything works fine. I do not understand why. Here is my C code:</p>
  
  <pre><code>int main(void){
  
      int Nstep = 348;
  
      //omitted part...
  
      FILE *pipe = fopen("plot.txt", "w+");
  
      while (n&lt;Nstep) {
          pos[n+1] = pos[n] + v[n]*h;
          v[n+1] =  v[n] + h * Fx(pos[n]);
  
          fprintf(pipe, "%d %05.3lf\n", n, v[n]);
          n++;
          } 
  
      close(pipe);
  
      system("gnuplot -p -e \"plot 'plot.txt' using 1:2 with lines\"");
  
      return 0;    
  }
  </code></pre>
  
  <p>plot.txt example (Nstep = 10)</p>
  
  <pre><code>1 100.000
  2 99.000
  3 97.000
  4 94.010
  5 90.050
  6 85.150
  7 79.349
  8 72.697
  9 65.252
  10 57.079
  </code></pre>