Search code examples
gnuplot

convert x values to minutes or hours


assuming I have data values like those:

8.31
8.25
8.13
8.06
8.00
7.94
7.88

and it is known that they were taken 30 seconds apart each, how can I plot them as minutes or hours in the x axis? I am just confused by not having a separate time column and hpoing gnuplot can do that without adding a new time column to the data file...

I currently use only:

plot 'data.log' u 0:1 with lines lw 2

which of cause give a dimensionless x axis...


Solution

  • Assuming the first point starts at time zero, you can just multiply the pseudo column with 30 to get seconds, e.g.:

    plot 'data.log' using ($0 * 30):1 with lines linewidth 2
    

    Output:

    Plot with x axis tics showing seconds

    As mentioned by Dan in the comments, if you want minutes just divide by 60:

    plot "data.log" using ($0 * 30 / 60):1 with lines linewidth 2
    

    Plot with x axis tics showing seconds