Search code examples
plotgnuplot

Label a point when the x-axis is time/date


my data.dat looks like this

2018-01-15, 3268
2018-02-07, 3783
2018-02-08, 7569

And the relevant parts of my plot.plt looks like this

set timefmt "%Y-%m-%d"
set xdata time
set format x "%b/%d"

What I am trying to do is plot the data and put a label (with the text "label") on a point thats 2018-02-28 on the x-axis and 5000 on the y-axis, but I'm not getting the following lines to work.

plot "data.dat" using 1:2 w lines ls 1
set label 1 at  2018-02-08, 5000 'label' center rotate by 45 front

The error I get is shown on the following line is pointing a ^ on the date-part of the "set label"

"plot.plt", line 39: unexpected or unrecognized token

Any idea how I can place this label?


Solution

  • The answer was as in the comments above:

    1. Enclose the date in quotes "2018-02-08"
    2. Move the set label 1 at "2018-02-08" ... before the plot "data.dat" ...