I was trying to use gnuplot to graph a CSV file containing date-time and temperature but it was producing some strange results when it worked (mainly just one line straight up in the middle of the graph). This is the code:
set xdata time set timefmt '%Y-%m-%d %H:%M:%s' set xrange["2013-05-29 00:00:00":"2013-06-04 00:00:00"] set datafile separator ',' plot 'weather.csv' using 1:2
This is a sample of the data:
2013-05-29 18:30:00,20.0 2013-05-29 21:29:00,14.0 2013-05-29 22:29:00,13.0 2013-05-29 23:29:00,12.0 2013-05-30 08:28:00,13.0 2013-05-30 09:30:00,14.0
It was getting an error:
Can't plot with an empty x range!
So I typed the commands at the command line:
gnuplot> set xdata time gnuplot> set timefmt '%Y-%m-%d %H:%M:%s' gnuplot> set xrange["2013-05-29 00:00:00":"2013-06-04 00:00:00"] gnuplot> show xrange set xdata time set xrange [ "1970-01-01 00:00:-946684800" : "1970-01-01 00:00:-946684800" ] noreverse nowriteback gnuplot> show
What am I doing wrong?
According to this documentation,
%s is interpreted as
seconds since the Unix epoch (1970-01-01 00:00 UTC)
This explains the output from your
show xrange as well. For this date interpretation, your
xrange will come up empty.
If you use
second, 0-60) instead, your example will plot fine:
set timefmt '%Y-%m-%d %H:%M:%S'
Answer author Schorsch
Tickanswer.com is providing the only single recommended solution of the question Setting xrange in gnuplot producing strange result under the categories i.e csv , gnuplot , . Our team of experts filter the best solution for you.