I am capturing data from a sensor and it is being outputted into a .dat file. I want to export this information into a plot using gnuplot and have it be completely autonomous to only display the last 7 days worth of collected data (no hard coding the dates, should adjust based on system time using the time() function)
If I hard code the date range, i.e. set xrange ["07-25-16":"08-25-16"], I receive no errors and the code/plot runs smoothly. However, if I try to plot a function of time for the past seven days using the time() function, I receive the following error:
line 0: illegal month
Here is my collected data from the sensor (output.dat):
07-21-2015 15:21 0 0 0
07-23-2016 15:21 0 0 0
07-29-2016 15:21 0 1 -1
07-29-2016 15:21 1 1 0
07-29-2016 15:21 2 1 1
07-29-2016 15:21 3 1 2
07-29-2016 15:21 3 2 1
07-29-2016 15:21 4 2 2
07-29-2016 15:21 5 2 3
07-29-2016 15:21 5 3 2
07-29-2016 15:21 5 4 1
07-29-2016 15:21 5 5 0
07-29-2016 15:22 6 5 1
07-29-2016 15:22 6 6 0
07-29-2016 15:23 1 0 1
07-29-2016 15:23 1 1 0
Here is the code I am running (commented out the xrange that works, replaced with the one I am trying to implement):
set xdata time
set timefmt "%m-%d-%Y %H:%M"
xstart=strftime("%m-%d-%Y %H:%M", time(0) - 604800)
xend=strftime("%m-%d-%Y %H:%M", time(0))
#set xrange ["07-25-16":"08-25-16"]
set xrange ["xstart" : "xend"]
set format x "%m-%d\n%H:%M"
set title "Sensor Data"
set xlabel "Date\nTime"
set ylabel "Number of Sensor Trips"
plot "output.dat" using 1:4 skip 1 t "Exits" with linespoints, \
"output.dat" using 1:3 skip 1 t "Entrances" with linespoints
set term png
set output "output.png"
replot
set term x11
Any help would be greatly appreciated. Thank you!
Edit 1 -- Gnuplot now not plotting correctly after string fix (removed "" from the xrange to only show: set xrange [xstart:xend]:

Any ideas on how to fix?
