Trendline with gnuplot 4.6 patchlevel 6 ?

Hello,

I've a question about Gnuplot 4.6 patchlevel 6 and how to trace a trendline. First of all, I'm bound to use this verison of Gnuplot.

I've this data :

019-10-08-13-37;28.7297
2019-10-08-18-00;28.6886
2019-10-09-00-00;28.5557
2019-10-09-06-00;28.5316
2019-10-09-12-00;28.4314
2019-10-09-18-00;28.3764
2019-10-10-00-00;28.3501
2019-10-10-06-00;28.3931
2019-10-10-12-00;28.3554
2019-10-10-18-00;28.352
2019-10-11-00-00;28.4302
2019-10-11-06-00;28.5046
2019-10-11-12-00;28.5069
2019-10-11-18-00;28.5622
2019-10-12-00-00;28.5789
2019-10-12-06-00;28.7112
2019-10-12-12-00;28.7805
2019-10-12-18-00;28.9048
2019-10-13-00-00;28.9547
2019-10-13-06-00;29.1321
2019-10-13-12-00;29.3369
2019-10-13-18-00;29.4005
2019-10-14-00-00;29.4929
2019-10-14-06-00;29.4671
2019-10-14-12-00;29.3814
2019-10-14-18-00;29.2552
2019-10-15-00-00;29.1763
2019-10-15-06-00;28.9525
2019-10-15-12-00;28.7233
2019-10-15-18-00;28.5996
2019-10-16-00-00;28.5013
2019-10-16-06-00;28.5697
2019-10-16-12-00;28.5678
2019-10-16-18-00;28.5949
2019-10-17-00-00;28.584
2019-10-17-06-00;28.7037
2019-10-17-12-00;28.7675
2019-10-17-18-00;28.7836
2019-10-18-00-00;28.7636
2019-10-18-06-00;28.8028
2019-10-18-12-00;28.8263
2019-10-18-18-00;28.8567
2019-10-19-00-00;28.9264
2019-10-19-06-00;29.0445
2019-10-19-12-00;29.169
2019-10-19-18-00;29.2589
2019-10-20-00-00;29.3171
2019-10-20-06-00;29.4821
2019-10-20-12-00;29.6053
2019-10-20-18-00;29.612
2019-10-21-00-00;29.6294
2019-10-21-06-00;29.4928
2019-10-21-12-00;29.3694
2019-10-21-18-00;29.2817
2019-10-22-00-00;29.2084
2019-10-22-06-00;29.0708
2019-10-22-12-00;28.9547
2019-10-22-18-00;28.8819
2019-10-23-00-00;28.8077
2019-10-23-06-00;28.8288
2019-10-23-12-00;28.8723
2019-10-23-18-00;28.8649
2019-10-24-00-00;28.843
2019-10-24-06-00;28.7775
2019-10-24-12-00;28.6546
2019-10-24-18-00;28.6232
2019-10-25-00-00;28.5375
2019-10-25-06-00;28.4416
2019-10-25-12-00;28.4125
2019-10-25-18-00;28.4502
2019-10-26-00-00;28.4878
2019-10-26-06-00;28.6917
2019-10-26-12-00;28.9151
2019-10-26-18-00;29.0476
2019-10-27-00-00;29.1354
2019-10-27-06-00;29.308
2019-10-27-12-00;29.4389
2019-10-27-18-00;29.4221
2019-10-28-00-00;29.4532
2019-10-28-06-00;29.2581
2019-10-28-12-00;29.0459
2019-10-28-18-00;28.8653
2019-10-29-00-00;28.7442
2019-10-29-06-00;28.4954
2019-10-29-12-00;28.2602
2019-10-29-18-00;28.1009
2019-10-30-00-00;28.01
2019-10-30-06-00;28.0128
2019-10-30-12-00;28.0135
2019-10-30-18-00;27.9668
2019-10-31-00-00;27.9547
2019-10-31-06-00;28.2547
2019-10-31-12-00;28.4136
2019-10-31-18-00;28.4243
2019-11-01-00-00;28.3241
2019-11-01-06-00;28.485
2019-11-01-12-00;28.6411
2019-11-01-18-00;28.6551
2019-11-02-00-00;28.6858
2019-11-02-06-00;28.7458
2019-11-02-12-00;28.8185
2019-11-02-18-00;28.9744
2019-11-03-00-00;29.033
2019-11-03-06-00;29.1647
2019-11-03-12-00;29.2878
2019-11-03-18-00;29.3621
2019-11-04-00-00;29.4238
2019-11-04-06-00;29.3396
2019-11-04-12-00;29.3646
2019-11-04-18-00;29.2539
2019-11-05-00-00;29.1897
2019-11-05-06-00;29.0275
2019-11-05-12-00;28.876
2019-11-05-18-00;28.7917
2019-11-06-00-00;28.7308
2019-11-06-06-00;28.7278
2019-11-06-12-00;28.7363
2019-11-06-18-00;28.6857
2019-11-07-00-00;28.6847
2019-11-07-06-00;28.6337
2019-11-07-12-00;28.5574
2019-11-07-18-00;28.5175
2019-11-08-00-00;28.4502
2019-11-08-06-00;28.5018
2019-11-08-12-27;28.5358
2019-11-08-18-00;28.5503
2019-11-09-00-00;28.5374
2019-11-09-06-00;28.7383
2019-11-09-12-00;28.8752
2019-11-09-18-00;28.9863
2019-11-10-00-00;29.0814
2019-11-10-06-00;29.191
2019-11-10-12-00;29.3154
2019-11-10-18-00;29.3861
2019-11-11-00-00;29.4667
2019-11-11-06-00;29.4337
2019-11-11-12-00;29.3328
2019-11-11-18-00;29.2355
2019-11-12-00-00;29.1774
2019-11-12-06-00;28.9524

And this gnuplot script :

set terminal png truecolor size 12000,520 background rgb "#eff1f0"
set output "/xxx/xxx/xxx/xxx/test.png"
set grid
set style line 1 \
    linecolor rgb '#0060ad' \
    linetype 1 linewidth 2 \
    pointtype 7 pointsize 1.5

set offsets 0.5,0.5,0,5
set bmargin 13
show offsets
set datafile separator ";"
set key left
set xtics rotate by 90 offset 0,graph -0.6
set format y "%g"
myLabel(n) = sprintf("%g",n)

plot "/xxx/xxx/xxx/xxx/data.txt" using 2:xtic(1) with linespoints linestyle 1 title "df line in Gb", \
 '' using 0:2:(myLabel($2)) w labels offset 0,1 notitle          


( Sorry for the size of the pictures )

I want to add a trendline, I know how to make it basically :

set terminal png truecolor size 12000,520 background rgb "#eff1f0"
set output "/xxx/xxx/xxx/xxx/test.png"
set grid
set style line 1 \
    linecolor rgb '#0060ad' \
    linetype 1 linewidth 2 \
    pointtype 7 pointsize 1.5

set offsets 0.5,0.5,0,5
set bmargin 13
show offsets
set datafile separator ";"
set key left
set xtics rotate by 90 offset 0,graph -0.6
set format y "%g"
myLabel(n) = sprintf("%g",n)
f(x) = a*x + b
fit f(x) "/xxx/xxx/xxx/xxx/data.txt" u 0:2 via a,b

plot "/xxx/xxx/xxx/xxx/data.txt" using 2:xtic(1) with linespoints linestyle 1 title "df line in Gb", \
'' using 0:2:(myLabel($2)) w labels offset 0,1 notitle, \
f(x) with l lc "black" title "trendline"

But I would like to put a linear fit with extrapolation. The first value of my trendline will be the first value of my datas and I would like to put a variable on my gnuplot script which define the end of the trendline.

So thr first data will be 2019-10-08-13-37;28.7297. I would like that gnuplot take itself the first date in my data.txt and I would like to put the last date by myself in the script, for example "EndDate:2020-09".

Could you show me how to do that ?

Thanks ! :slight_smile: