Search code examples
timeformatgnuplotaxisaxis-labels

labels to the axis - conver int (second) to hours


How can I make axis labels in the HOURS: MINUTES format (10:00 for example), if the data on the axis are represented as integers in the range [0...N]?

For example:

range [0..43200]
axis labels: 00:00 04:00 08:00 12:00 

seconf example:

range [28800..172800]
axis labels: 08:00 16:00 24:00 08:00 16:00 24:00 

When I use code:

set xdata time
set format x "%H:%M"

it does not work correctly :(


Solution

  • I assume you want that the time does not wrap at 24:00? i.e. 32:00 40:00 48:00 instead of 08:00 16:00 24:00 ? See help time_specifiers

    Simple test code:

    reset session
    
    set xdata time
    set format x "%tH:%tM"
    set xrange [0:180000]
    
    plot x
    

    which gives: enter image description here