1

i´m plotting a Dataset and performed two linear fit on the resulting graph. I plotted the results and got a graph with two straight lines. The two lines run from one end of the plot to the other. Do somebody know how to restrain the plot of the lines to a certain interval.

For example: the line of the first fit runs from x=800:1100 and the line of the second fit runs from x=900:1600.

The parameters of the whole plot are y= -2:9; x= 800:1600

esrehmki
  • 177
  • 1
  • 7
  • Is this a different question from this one (http://stackoverflow.com/questions/17110310/how-can-i-reduce-the-linear-fit-plot-to-a-certain-interval/17111982#17111982)? – andyras Jun 14 '13 at 23:08
  • it´s about the same problem. but i had the feeling, that i formulated the title wrong and that the answer you gave me was the correct one for the title. when i adjust my plot with the solution you suggested i change the interval for the whole plot. but ich just want to shorten the plotted fitting lines. – esrehmki Jun 15 '13 at 05:59
  • I am a little unclear still as to how this is a different issue than the one addressed in the other question. Could you post an example image of what the plot looks like now, and explain how you would like it to look different? – andyras Jun 16 '13 at 15:24

1 Answers1

1

You can use the fact that gnuplot ignores expressions like 1/0 and define a sort of indicator function:

f1(x) = 2.0*x + 1.0
f2(x) = x/3.0 + 2.0
ind(x, A, B) = 1.0/((x>A)*(x<B))

plot [800:1600] f1(x)*ind(x, 800, 1100), f2(x)*ind(x, 900, 1600)
slitvinov
  • 5,693
  • 20
  • 31