Gnuplot:类似示波器的线型?

Gnuplot:类似示波器的线型?,gnuplot,Gnuplot,在Gnuplot中,是否可以模拟模拟示波器的绘图风格,即在较大振幅下更细+更暗的线,如下图所示: 您在示波器记录道中看到的效果不是由于振幅,而是由于绘制记录道时的变化率。如果您知道该变化率,并且可以将其作为第三列值提供给gnuplot,那么您可以使用它在绘制线条时调节线条颜色: plot 'data' using 1:2:3 with lines linecolor palette z 我不知道哪种调色板最适合您的目的,但这里是一个近似使用一个明显的,已知的,导数函数 set pale

在Gnuplot中,是否可以模拟模拟示波器的绘图风格,即在较大振幅下更细+更暗的线,如下图所示:


您在示波器记录道中看到的效果不是由于振幅,而是由于绘制记录道时的变化率。如果您知道该变化率,并且可以将其作为第三列值提供给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

您在示波器记录道中看到的效果不是由于振幅,而是由于绘制记录道时的变化率。如果您知道该变化率,并且可以将其作为第三列值提供给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

对于厚度变化,可以稍微上下移动曲线,并填充它们之间的区域

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


这不允许可变颜色,但视觉效果类似。

对于厚度变化,可以稍微上下移动曲线,并填充曲线之间的区域

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

这不允许可变颜色,但视觉效果类似。

另一种方法:

正如@Ethan已经指出的,强度在某种程度上与运动速度成正比,即导数。如果波形为
sin(x)
,则导数为
cos(x)
。但是如果你提供了数据呢?然后你必须用数值计算导数。 此外,根据背景的不同,线条应从白色(最小导数)渐变为完全透明(最大导数),即,应使用导数更改透明度

  set palette gray
  set samples 1000
  plot '+' using ($1):(sin($1)):(abs(cos($1))) with lines linecolor palette
代码:

### 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
###示波器“模仿”
重置会话
设置术语wxt尺寸500400对接#选项对接,否则将获得重叠点
设置大小比4/5
设置样本1000个
设置xrange[-5:5]
#创建一些测试数据
f(x)=1.5*sin(15*x)*(cos(1.4*x)+1.5)
设置表$Data
绘图“+”u1:(f($1))w表
未设置的表
设置xtics轴1格式“”
设置MX5
设置网格xtics ls-1
设置Y范围[-4:4]
设置ytics轴1格式“”
设置粘液5
将网格ytics设置为ls-1
彩色屏幕=0x28a7e0
将obj 1 rect从屏幕0,0设置为屏幕1,1后方
设置obj 1填充固体1.0 fc rgb彩色屏幕
x0=y0=NaN
导数(x,y)=(dx=x-x0,x0=x,x-dx/2,dy=y-y0,y0=y,dy/dx)#近似导数
#获取最小/最大导数
设置表$Dummy
图n=0$Data u(d=abs(导数($1,$2)),n=n+1,nd?dmin=d:dmin),(dmax另一种方法:

正如@Ethan已经指出的,强度在某种程度上与运动速度成正比,即导数。如果你将
sin(x)
作为波形,导数是
cos(x)
。但是如果你给出了数据呢?那么你必须用数字计算导数。 此外,根据背景的不同,线条应从白色(最小导数)渐变为完全透明(最大导数),即,应使用导数更改透明度

  set palette gray
  set samples 1000
  plot '+' using ($1):(sin($1)):(abs(cos($1))) with lines linecolor palette
代码:

### 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
###示波器“模仿”
重置会话
设置术语wxt尺寸500400对接#选项对接,否则将获得重叠点
设置大小比4/5
设置样本1000个
设置xrange[-5:5]
#创建一些测试数据
f(x)=1.5*sin(15*x)*(cos(1.4*x)+1.5)
设置表$Data
绘图“+”u1:(f($1))w表
未设置的表
设置xtics轴1格式“”
设置MX5
设置网格xtics ls-1
设置Y范围[-4:4]
设置ytics轴1格式“”
设置粘液5
将网格ytics设置为ls-1
彩色屏幕=0x28a7e0
将obj 1 rect从屏幕0,0设置为屏幕1,1后方
设置obj 1填充固体1.0 fc rgb彩色屏幕
x0=y0=NaN
导数(x,y)=(dx=x-x0,x0=x,x-dx/2,dy=y-y0,y0=y,dy/dx)#近似导数
#获取最小/最大导数
设置表$Dummy
图n=0$Data u(d=abs(导数($1,$2)),n=n+1,nd?dmin=d:dmin,(dmax