Gnuplot date/time in x axis

Gnuplot doesn't actually expect time data to be in quotes, so you have to tell it:

set timefmt '"%Y-%m-%d %H:%M:%S"'

You can put the double quotes inside single quotes as I did here, or escape the quotes:

set timefmt "\"%Y-%m-%d %H:%M:%S\""

the same applies to your xrange specification:

set xrange ['"2013-07-21 16:00"':'"2013-07-22 16:00"']

If you delete the quotes in the data file, then you can use the formatting you originally had, except the column numbers will be shifted over by 1 since the date takes up two columns without the quotes.


It seems like the answer is yes, the problem was the space.

doing this seems to fix it:

set datafile separator ","

and actually separating the times and data with commas.


As far as I understood, the order of instructions is important, I could afford it using:

  • The timefmt is for data and has to be the same for xrange
  • format x is only for displaying

            set xdata time
            set timefmt "%Y%m%dT%H%M%S"
            set format x "%Y-%m-%d\n%H:%M:%S"
            # or with bash variables: set xrange ["$l_start_dt":"$l_end_dt"]
            set xrange ["20190620T000000":"20190628T000000"]