Plot range for line of fit using date on the x-axis in gnuplot -
i trying plot fit function (col 3 versus col 7) dataset given below
28-08-1991 20-12-1992 24-04-1992 -263347200 -221875200 -242611200 0.060859 20-12-1992 02-09-1993 27-04-1993 -221875200 -199756800 -210816000 0.064681 10-09-1996 13-09-1997 13-03-1997 -104371200 -72576000 -88473600 0.095728 ......
i script plot fit range of dates, between 1995 2003. unable range function right since gnuplot handle dates past year 2000.
please find code below.
set xdata time set timefmt "%d-%m-%y" set xrange ["01-01-1991":"01-01-2015"] set yrange [0.0:0.4] offset = 24*60*60 f(x) = 1.e-7*m*(x-offset)+c fit f(x) "file" using 3:7 via m,c set fit logfile 'file.log' plot '(x < "24-02-1993" ) ? f(x) : 1/0' title "best fit" lines ls 5
the variable x
in plot
contain time in form of seconds since 1/1/1970. in order compare date, need convert date same format strptime
.
if additionally remove '
around function plot in mwe, get:
plot (x<strptime("%d-%m-%y","24-02-1993"))?f(x):1/0 title "best fit" lines ls 5
note you've fitted f(x)
on whole dataset, not on dates before 24-02-1993, it's plot restricted these dates.
Comments
Post a Comment