title: Can I do math on the independent variable for display on the x axis in Gnuplot?
body: <p>Here is my code:</p>
  
  <pre><code>set title "Samples plot"
  set xlabel "Samples"
  set ylabel "Volts"
  set yrange [15:30]
  set grid
  unset mouse
  set timestamp
  set key center left
  plot "py.out" using 1:2 skip 2 with lines lw 2 t "Battery", \
       "py.out" using 1:3 skip 2 with boxes t "Inverter", \
       26.0 t "Inverter on", \
       24.8 lw 4 t "Nominal", \
       23.0 t "Inverter off"
  </code></pre>
  
  <p>The data file looks something like this:</p>
  
  <pre><code>1     22.50    0
  2     22.56    0
    (etc, until the inverter turns on at 26) 
  5199  25.85    0
  5200  26.45    23
  5201  24.80    23
    (etc, until it drops below 23 - then the controller cuts it off)
  </code></pre>
  
  <p>Obviously, the sample number is the independent variable.  The sampling runs at about every 2 seconds.</p>
  
  <p>I am mostly where I want things to be, except for one nagging question about Gnuplot.</p>
  
  <p>Here is the plot I am getting:</p>
  
  <p><a href="https://i.stack.imgur.com/zKYyW.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/zKYyW.png" alt="enter image description here"></a></p>
  
  <h2>So my question is:</h2>
  
  <p>How can I utilize Gnuplot to convert the sample numbers into times?  This system takes about 1800 samples per hour.   I am willing to add code that sets the first sample to be a specific time and to adjust the number of samples per hour to dial it in to match actual times.</p>
  
  <h2>More information - New Day:</h2>
  
  <p>So today I have 9,000 samples covering from 6:00 to 11:00, and my plot looks like this:</p>
  
  <p><a href="https://i.stack.imgur.com/n5Jem.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/n5Jem.png" alt="enter image description here"></a></p>
  
  <p>Then with the plot command changed to this:</p>
  
  <pre><code>    plot "py.out" using (int($1/1800)+6):2 skip 2 with lines lw 2 t "Battery", \
           "py.out" using (int($1/1800)+6):3 skip 2 with boxes t "Inverter", \
  </code></pre>
  
  <p>Using the same data, I get a graph that looks like this:</p>
  
  <p><a href="https://i.stack.imgur.com/Ljm3j.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Ljm3j.png" alt="enter image description here"></a></p>
  
  <p>Doing math within the plot command is causing it to change more than just the axis markings.  </p>