Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mutiple fit lines on same plot in gnuplot?

I'm attempting to try some simple regression lines as the basis of a gnuplot graph. However, no matter what I do, I can't get more than one fit line on a graph. Is this even possible? Here's my (current) gnuplot program....

set title "Foo" font "Arial Bold,14"
set term epscairo size 8,5
set style line 1 lw 0 pt 7 lc rgb "black"
set key outside
set pointsize .75
set ylabel "Y Range" font "Arial Bold"
set xlabel "X Range" font "Arial Bold"
set grid ytics
set yrange [-1:100]
set xrange [1:80]
set output 'graph.ps'

f1(x) = a1*x + b1
fit f1(x) "data/dvdate/1" using 2:3 via a1,b1

f2(x) = a1*x + b1
fit f2(x) "data/dvdate/2" using 2:3 via a1,b1

f3(x) = a1*x + b1
fit f3(x) "data/dvdate/3" using 2:3 via a1,b1

plot f1(x) title '# 1', f2(x) title '# 2', f3(x) title '# 3'

The result is that I have get one .ps file with one line it (not overlaying other lines) with the three data series labels.

like image 821
docSquale Avatar asked Apr 03 '26 02:04

docSquale


1 Answers

you need to use different variables (a1,b1) in each fit.

f2(x) = a2*x + b2
fit f2(x) "data/dvdate/2" using 2:3 via a2,b2
like image 174
agentp Avatar answered Apr 08 '26 15:04

agentp



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!