在Gnuplot中是否可以模仿模拟示波器的绘制风格,这意味着更大幅度的thinner+dimmisher线,就像这样:

发布于 2020-01-25 06:57:51
您在示波器轨迹中看到的效果不是由振幅引起的,而是由于绘制轨迹时的变化率造成的。如果您知道变化率,且可以将其作为第三列值提供给gnuplot,则可以在绘制时使用它来调整线条颜色:
plot 'data' using 1:2:3 with lines linecolor palette z我不知道哪种调色板最适合你,但这里有一个使用一个明显的,已知的,导数的函数的近似值。
set palette gray
set samples 1000
plot '+' using ($1):(sin($1)):(abs(cos($1))) with lines linecolor palette

发布于 2020-01-31 23:34:38
对于厚度变化,可以稍微上下移动曲线,并填充它们之间的区域。
f(x) = sin(2*x) * sin(30*x)
dy = 0.02
plot '+' u 1:(f(x)+dy):(f(x)-dy) w filledcurves ls 1 notitle

这不允许变色,但视觉效果是相似的。
发布于 2020-04-17 06:42:19
另一种方法:
正如@Ethan已经说过的,强度在某种程度上与运动速度成正比,即导数。如果使用sin(x)作为波形,则导数为cos(x)。但是如果你已经给出了数据呢?然后你必须用数值计算导数。此外,根据背景的不同,线条应该从白色(最小导数)淡出到完全透明(最大导数),即您应该使用导数更改透明度。
代码:
### oscilloscope "imitation"
reset session
set term wxt size 500,400 butt # option butt, otherwise you will get overlap points
set size ratio 4./5
set samples 1000
set xrange[-5:5]
# create some test data
f(x) = 1.5*sin(15*x)*(cos(1.4*x)+1.5)
set table $Data
plot '+' u 1:(f($1)) w table
unset table
set xtics axis 1 format ""
set mxtics 5
set grid xtics ls -1
set yrange[-4:4]
set ytics axis 1 format ""
set mytics 5
set grid ytics ls -1
ColorScreen = 0x28a7e0
set obj 1 rect from screen 0,0 to screen 1,1 behind
set obj 1 fill solid 1.0 fc rgb ColorScreen
x0=y0=NaN
Derivative(x,y) = (dx=x-x0,x0=x,x-dx/2,dy=y-y0,y0=y,dy/dx) # approx. derivative
# get min/max derivative
set table $Dummy
plot n=0 $Data u (d=abs(Derivative($1,$2)),n=n+1,n<=2? (dmin=dmax=d) : \
(dmin>d ? dmin=d:dmin), (dmax<d?dmax=d:dmax)) w table
unset table
myColor(x,y) = (int((abs(Derivative(column(x),column(y)))-dmin)/(dmax-dmin)*0xff)<<24) +0xffffff
plot $Data u 1:2:(myColor(1,2)) w l lw 1.5 lc rgb var not
### end of code结果:

https://stackoverflow.com/questions/59904360
复制相似问题