0

I am currently passing arguments to gnuplot via shell.

I am extracting data that has a timescale in milliseconds (just a raw length) The x axis is displayed with these raw values (ie 6000, 120000, 18456...) I would like to convert it to minutes or seconds via the arguments I am passing to gnuplot via my script (shell). I currently have the following argument:

"set title 'temperature stress test results for " + $sn + " on " + $datetime + "
                set term png size 1450, 800
                set xlabel 'Time(ms)'
                set ylabel 'Temperature (C)'
                set key right top
                set autoscale
                set yrange [20:55]
                set format x '%.0f'
                set grid
                set datafile sep ','
                set output '" + $pngfile + "'
                plot  '" + $_ + "' using 1:3 with lines title 'heater', '" + $_ + "' using 1:9 with lines title 'cam0', '" + $_ + "' using 1:10 with lines title 'cam1', '" + $_ + "' using 1:11 with lines title 'cam2', '" + $_ + "' using 1:12 with lines title 'cam3'"

is there a way to rescale the x axis ? I was expecting something like (x = x / 60000) to get it in minutes for example

trexgris
  • 362
  • 3
  • 14

1 Answers1

1

Gnuplot's basic unit for time data is one second. You have data in milliseconds, so you will need to divide by 1000 before interpreting it as a time. Because your data is an absolute number of [milli]seconds rather than a clock time, you should use the relative time formats tH tM tS. These permit fractional values, and will not wrap at clock intervals. I.e. the minute count does not reset to 0 when it hits 60.

To plot input data given in millisecond on an x axis labelled in Minutes and Seconds to millisecond precision:

set xlabel 'Time (minutes:seconds)'
set xtics time format "%tM:%.3tS"
plot $DATA using ($1/1000.):3 title 'whatever'

Example:

plot sample [-1000:10000] '+' using ($1/1000.):1 

enter image description here

Ethan
  • 13,715
  • 2
  • 12
  • 21
  • Thanks for your answer. Do you know how I would apply that to the other columns i specified in my code ? In your case you plot the time on your sample (meaning column 1 or column 1 itself, but I have several that are using the x axis as a reference, hence I am not sure how to use your syntax: ($1/1000.):1 Or do i need to specify this format to all the columns ? – trexgris Oct 08 '19 at 17:35
  • `set xtics` has nothing to do with columns. It specifies how to label the x-axis when drawing the plot. From your example I understood the millisecond data to be in column 1, while the other columns contained temperature readings. Are you asking how to scale temperature also? – Ethan Oct 08 '19 at 18:45