功能消失接近零 [英] The function disappear close to zero
问题描述
我在绘制拟合函数时遇到问题.
I have problem with plotting fitted function.
绘制函数的接近零的部分消失,并与双曲线或根本不存在的双曲线相连.仅当我将set xrange
更改为小于0的值时,才会发生这种情况.我必须这样做,因为我有很多数据点都接近零,因此如果不进行更改,它将看起来非常难看.
The part of the ploted function close to zero disappears and connected with the hyperbola or something which should not be there at all. This happen only if I change set xrange
to something smaller than 0. I have to do this because I have lot of data points to close zero so it would look very ugly if I would not changed it.
我尝试使用条件x>0?f(x):1/0
,但这无济于事.双曲线消失了,但功能并未继续发挥作用.
I tried to use conditionals x>0?f(x):1/0
but it does not help. The hyperbola disappear but the function does not continue down as it should.
我使用以下代码:
set terminal postscript eps size 3.5,2.62 enhanced color
set output "a.eps"
set xrange [-1:]
f(x)=a*b*x/(1+a*x)
fit f(x) "./a" via a, b
plot "./a" w p title "", f(x) w l title "Langmuir isotherm"
推荐答案
那只是抽样问题.默认采样率为100
(show samples
),不足以显示快速变化的功能.通过以下方式提高采样率:
That is simply a matter of sampling. The default sampling rate is 100
(show samples
), which isn't enough to show fast-varying functions. Increase the sampling rate with e.g.
set samples 1000
正确绘制功能.
第二点是,如果没有样本正好位于该位置,则无法正确显示不连续性.请考虑以下图解以说明这一点:
A second point is, that discontinuities aren't shown properly if no sample is located exactly at that position. Consider the following plot to demonstrate this:
set xrange [-1:1]
set multiplot layout 2,1
set samples 100
plot 1/x
set samples 101
plot 1/x
unset multiplot
因此,如果要在不连续点的两侧正确绘制函数,则必须将不连续点周围的小区域定义为未定义,或者分别在左右两侧绘制部分:
So, if you want to plot the function correctly on both sides of the discontinuity, you must either define a small region around the discontinuity as undefined, or you plot the parts on the left and right separately:
set xrange [-1:]
f(x)=a*b*x/(1+a*x)
fit f(x) "./a" via a, b
left(x) = (x < -1/a ? f(x) : 1/0)
right(x) = (x > -1/a ? f(x) : 1/0)
plot "./a" w p title "", left(x) w l lt 2 title "Langmuir isotherm", right(x) w l lt 2 notitle
这篇关于功能消失接近零的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!