Gnuplot - "set xrange [x_min: x_max]] limits the range used for the fit function?

Simple question - the range drawn on the chart can be changed using the command set xrange [x_min:x_max]

.

Does this command also limit the range used when setting a function using gnuplot's fit tools? Is there a way to manually specify the range to use for fitting features? (Can we assume this is a command every

? Do I need to overload xrange

with every

?)

The reason I am asking is because I am using xrange to output the results zoomed in the low x region to see the transient behavior more clearly, but I think it might be "chipping" the values ​​from the fitting function when large x values ​​outside the xrange selected?

+3


source to share


2 answers


This is an old question, but the current answer is incorrect: the current settings xrange

affect the range used for the fit unless an explicit range is specified as part of the fit command. This is easy to see with a simple example: if you have a data file test.dat

containing

1 1
2 2
3 3
4 4
5 6
6 8
7 10
8 12

      

and use a linear fit you get

fit a+b*x "test.dat" via a,b
plot "test.dat" w p, a+b*x w l

      

enter image description here



and correspond to the parameters (a, b) = (- 1.42, 1.59). However, if this is the first time you installed xrange

, you will get

set xrange [4:8]
fit a+b*x "test.dat" via a,b
plot "test.dat" w p, a+b*x w l

      

enter image description here

and correspond to the parameters (a, b) = (- 4.2).

This is at least the current behavior of gnuplot 5.2, but this old thread from 2009 suggests this has been the behavior for quite some time.

+3


source


set xrange [x_min:x_max]

does not affect the range used when fitting the function.

With a command fit

(the same is true for plot

) you can explicitly limit the range to match the variable with the following syntax:

[{dummy_variable=}{<min>}{:<max>}]

      



For example, you can limit the range for the x-axis:

fit [min:max] f(x) "filename"

      

+1


source







All Articles