1

I have data to plot in files structured like this:

(timestamp MegaBytes)
1487936469 0.003617
1487936470 0.081604
1487936471 0.244869
1487936472 0.322519
1487936473 0.242145
1487936474 0.34596
1487936475 0.385525
1487936476 0.324402
1487936477 0.154996
1487936478 0.24336
1487936479 0.38952
1487936480 0.46152
...

plotting with

using 1:2 with lines lw 3
set xlabel "seconds"; set ylabel "MB"
set format x '%.0f'

enter image description here

The plot is fine, but the x axis (time) is not nice to see: is there a gnuplot command that allows me to shift from the x range [1487936469,last time stamp] to [0,last value] so that x axis values would start from 0 instead of 1487936469?

elmazzun
  • 1,066
  • 2
  • 18
  • 44

1 Answers1

2

I feel stupid to high five myself, but here's how I solved this:

gnuplot> set grid
gnuplot> set xlabel "seconds"
gnuplot> set ylabel "MB"

My files have .log extension: create a list of files to be logged.

gnuplot> list = system('ls *.log')

"u": using, "w l": with lines, "lw": line width

gnuplot> plot for [file in list] file u 1:2 w l lw 3 title file

After this plot, special variables have been set, check them with:

gnuplot> show variables all
    ...
    GPVAL_DATA_X_MIN = 1487936460.0 <- this is what I wanted
    ...

I will subtract GPVAL_DATA_X_MIN to all values in x axis: store it in a variable and replot ($1 is the first column, the one with timestamps):

gnuplot> MIN=GPVAL_DATA_X_MIN
gnuplot> plot for [file in list] file u ($1-MIN):2 w l lw 3 title file

enter image description here

Much better! Credit goes to this question and this question.

Community
  • 1
  • 1
elmazzun
  • 1,066
  • 2
  • 18
  • 44