How can i reduce the linear fit plot to a certain interval?

esrehmki picture esrehmki · Jun 14, 2013 · Viewed 8.6k times · Source

what i do is to fit two linear function´s to my data. i know how to select the data for the various fitting functions. My problem is that i want the fitted lines only to be plottet in a certain interval. What i did till now:

f(x) = a*x + b; fit [800:1250][-2:8] f(x) 'Daten.txt' u 1:2 via a,b   

g(x) = c*x + d; fit [1258:1650][-2:8] g(x) 'Daten.txt' u 1:2 via c,d                                                                            

plot "Daten.txt" u 1:2 w l, f(x) t title_f(a,b), g(x) t title_g(c,d)                                                            

it results in

a picture i´m not allowed to post...

How can i make the green fittin-line only to run from 800-1200 and the blue fitting-line from 1100-end?

Answer

andyras picture andyras · Jun 14, 2013

The syntax

plot [xmin:xmax] f(x)

(the same as for fit) restricts the plot to a certain range. So, you could do something like

plot "Daten.txt" u 1:2 w l, [800:1200] f(x) t title_f(a,b), [1100:] g(x) t title_g(c,d)