gnuplot

Why does Gnuplot date processing always render 01-01-1970?


My data file looks like this:

2025-11-07 4450786
2025-11-14 4347929
2025-11-21 4243246
2025-12-12 4292480
2025-12-19 4272879
2025-12-24 4326509

My script file is:

set   autoscale
unset log
unset label
set xtic auto rotate by -45
set ytic auto
set grid xtics ytics
set timefmt "%Y-%m-%d"
set decimal locale
set title "Everything"
set xlabel "Date"
set format x "%d-%m-%Y" timedate
set format y "%'7.0f"
set ylabel "Value"
set yr [0:4500000]
plot "stocks.csv" using 1 with lines title "" , "stocks.csv" using 2 with lines title ""

The resulting plot is fine except that every X axis tick is "01-01-1970".

I am using Gnuplot version 6.0.3.

What is wrong?


Solution

  • You did not set the x axis as a time scale:

    set xdata time
    

    See http://www.gnuplot.info/docs_6.0/loc17356.html

    You then need to adapt the selected columns: using 1:2