【问题标题】:How to make a transparent plotted point如何制作透明的绘图点
【发布时间】:2021-03-24 14:21:02
【问题描述】:

在这里,我试图在蜘蛛/雷达图上实现雷达效果。理想情况下,我希望在给定时间的情况下使绘制的线消失(例如,在 30 秒内,绘制的线消失为透明,我正在考虑像顺序颜色图一样更改或绘制的线被删除/清除),但这可能会导致问题。因此,如果绘制的线过渡/淡入透明将减少整体图上的混乱。这对我来说是可能的,但很棘手..

set grid ls 10

set xtics axis format "" scale 0
set ytics axis format ""

set size square

set style line 9 lt 1 lw 2 pt 2 ps 2

set multiplot layout 1,2

plot 'somedata' using 1:5 t "" w lp ls 9
unset multiplot

pause 90
replot

如何在 Gnuplot 中实现这一点? 在我的阅读中,我遇到了一种叫做 Lerp/Lerping 颜色的东西,但是我没有使用 Csharp 或 Unity。

输出显示需要淡出/清除的标记。 主要区别在于只有 1 而不是 9 作为 pitu

example of points that need to transition/fade to transparent

【问题讨论】:

  • 所以你需要一个时间敏感的过滤器。是否可以使用熊猫数据框并插入带有时间戳的绘图值,然后将该时间戳与当前时间进行比较以确定要在哪个时间窗口进行绘图?
  • 您的数据是什么样的?请显示一些示例行。您的数据文件会不断更新吗?您是否希望 gnuplot 循环运行,等待一段时间并绘制新数据点并淡化以前的数据点?请澄清。
  • 它在 Gnuplot 中的输出;不是每个说的数据。它可以是任何数据,问题是在绘图时绘制的结果从纯色更改/过渡到透明或从绘图中删除。我确信 Gnuplots 功能能够做到这一点,因为情节是用上面显示的脚本编写的。

标签: python gnuplot color-mapping


【解决方案1】:

根据您的描述,我仍然不清楚您的期望是什么。所以,这里有一个我认为是“雷达效应”的例子,即淡化颜色。 它在一个while循环中设置透明颜色(检查help while),您可以按x(检查help bind)停止。 代码当然可以进一步优化,但我希望你能适应你的需要。

代码:

### attempt to mimic a radar screen
reset session

# create some test landscape
set xrange [-8:8]
set yrange [-8:8]
set samples 50 
set isosamples 50
set contour
set cntrparam level 5
set table $Data 
    splot (sin(1.3*x)*cos(.9*y)+cos(.8*x)*sin(1.9*y)+cos(y*.2*x))*3
unset table
unset contour
set angle degrees
Angle(dx,dy) = dx==dx && dy==dy ? dx==0 ? dy==0 ? NaN : \
               abs(sgn(dy))*180-sgn(dy)*90 : dx<0 ? 180+atan(dy/dx) : \
               dy<0 ? atan(dy/dx)+360 : atan(dy/dx) : NaN
r(x,y) = sqrt(x**2 + y**2)
set table $Contour
    plot $Data u (Angle($1,$2)):(r($1,$2)) index 1::1 
unset table

set size ratio 1
set polar
unset border
set border polar lc "green"
unset xtics
unset ytics
set format r ""
unset raxis
set rtics scale 0
set format t ""
set grid lw 2 lc "green"
set obj 1 rect from screen 0,0 to screen 1,1 fc "black" behind     # black background

stop = 0
bind x "stop=1"

$Data <<EOD
45    5
0   4
123   3.5
325   3.5
EOD

unset key
set trange [0:360]
set rrange [0:8]

alpha(a,a0)    = int((1-exp(-real(a)/a0))*255)<<24       # transparency "decay" 
myBaseColor    = 0x00ff00
myColorA(a)    = myBaseColor + alpha(a,45)               # decay for radar "beam"
AngleDiff(a,b) = b>a ? b-a : 360-a+b
myColorB(a,b)  = myBaseColor + alpha(AngleDiff(a,b),220) # decay for data

a=90; step=5
while (!stop) {
    a = a<step ? a=a+360-step : a-step
    do for [i=0:180] {
        set obj 100+i circle at 0,0 size 8 arc [a+i:a+i+2] fs solid noborder fc rgb myColorA(i) behind
    }
    plot $Data u 1:2:(myColorB(a,$1)) w p pt 7 lc rgb var, \
         $Contour u 1:2:(myColorB(a,$1)) w l lc rgb var
}
### end of code

结果:(从 wxt 终端使用 ScreenToGif 截屏)

【讨论】:

  • 看到您在这里提供的服务给我留下了深刻的印象;我去看看。非常棒.. A* 只看输出。
  • @Randolp 很高兴听到您喜欢它。糟糕,我刚刚注意到有一个 while 循环太多了。实验的剩余部分可能会修改代码。如果答案有帮助,请不要忘记接受和/或投票。如果您有任何问题,请告诉我。
  • 扫描仪上经过的绿色旋转是否/可以设置为一个时间,即在给定时间段内完成一次 360 度旋转扫描?
  • @Randolp 这不是给定的时间段。渐变的绘制效率不是很高。这是从 0 到 180 的循环,绘制了 181 条半透明的重叠弧。因此,这是可以绘制的最快速度。我没有检查CPU使用率。我不知道您可以轻松地绘制具有透明度的径向渐变。您是否需要在特定给定时间段内使用它?
  • gnuplot 对我来说是新的,那么我如何将您提供的示例应用于我必须从 txt/csv 文件加载的数据?在您的示例中,您设置了一个数据块,即$Data &lt;&lt;EOD 45 5 0 4 123 3.5 325 3.5 EOD
猜你喜欢
  • 1970-01-01
  • 2019-09-10
  • 1970-01-01
  • 2014-09-04
  • 2010-09-16
  • 1970-01-01
  • 1970-01-01
  • 2016-10-05
  • 1970-01-01
相关资源
最近更新 更多