Search code examples
gnuplot

How to restrict yrange for fit in gnuplot


I used the following scripts for plotting and fitting.

Data set:

2.474   2.659
0.701   2.637
0.582   2.643
0.513   2.666
0.403   2.639
0.308   2.615
0.218   2.561
0.137   2.537

Script:

reset
set key bottom right
f(x) = a*atan(x/b); a = 2.65; b = 2.5 
fit f(x) 'test.txt' u 1:2 via a,b
plot 'test.txt' u 1:2 w p not, f(x) t 'f(x)' 

The plot looks like this:

enter image description here

I am trying to restrict it between min_y and max_y. The following intuitive code failed horribly,

fit [y=2.537:2.659] f(x) 'test.txt' u 1:2 via a,b

Any suggestion on restriction would be highly appreciated! Thanks!


Solution

  • The range option only specifies which input points should be used, not restricting the output. So far as I can see from the manual, restrictions on the output value of f(x) aren't really possible (and so far as I can see from the problem, not really desirable).