Search code examples
timestampgnuplot

Make a plot with timestamp value in Gnuplot


I would like to make a graph of following dataframe in a text file in gnuplot.

00:40:10.223869 10.0.0.2 10.0.0.1 2617410 1 731025 3.820570716853684E-7 0.2792932708287964 606864 661379 617614 731025 1.9844739245003824E-7 5.645923197810635E-6 1.8597590551726972 7.439036220690789 0
00:40:10.223881 10.0.0.2 10.0.0.1 2617410 2 731025 7.641141433707368E-7 0.2792932708287964 606864 661379 617614 731025 1.1312066691175866E-6 1.0762202831517866E-5 10.601156408204401 7.439036220690789 0
00:40:10.223883 10.0.0.3 10.0.0.1 2617410 3 731025 1.1461712150561051E-6 0.2792932708287964 606864 661379 617614 731025 2.828080089155871E-6 1.5678571811653608E-5 26.503485329923905 7.439036220690789 0
00:40:10.223886 10.0.0.2 10.0.0.1 2617410 4 731025 1.5282282867414735E-6 0.2792932708287964 606864 661379 617614 731025 5.289067652564894E-6 2.0465118534828923E-5 49.566745820331214 7.439036220690789 0

I used the following code but still gnupot can not detect the X value(time stamp):

set timestamp "%H:%M:%S" offset 80,-2 font "Helvetica"
plot  "test.txt" using 1:5 title 'number of packets that sends'

The error is :

empty x range [0:0], adjusting to [-1:1]
     Bad format character

Also there is a error for this command:

plot  "test.txt" using 2:5 title 'number of packets that sends'

Please let me know what should I do to fix this probelm. Thanks.


Solution

  • The command set timestamp does not plot values with date and time, it places on the graph the time when the plot was created. You need to set the time format of your data and axis and tell gnuplot that you need a time scale on certain axis.

    set timefmt '%H:%M:%S'
    set xdata time
    set format x '%H:%M:%S'
    plot  "test.txt" using 2:5 title 'number of packets that sends'
    

    enter image description here