gpt4 book ai didi

Gnuplot:使用调色板时数据点的透明度

转载 作者:行者123 更新时间:2023-12-02 15:18:40 25 4
gpt4 key购买 nike

使用调色板时有没有办法绘制透明数据点?

我目前有以下代码:

set style fill transparent solid 0.2 noborder
set palette rgb 22,13,-22
plot 'mydata.dat' u 1:2:3 ps 0.3 palette

我的感觉是透明度被绘图命令的参数覆盖。

最佳答案

Is there a way to plot transparent data points when using palette?

如果您检查帮助调色板,您将找不到(或者我忽略了)有关调色板透明度的声明。看起来您可以以不同的方式为 RGB 设置调色板,但不能为 ARGB (A=透明的 Alpha channel )。所以,我认为调色板不可能具有透明度(如果我错了,请纠正我)。作为解决方法,您必须通过设置具有一定透明度的颜色来“手动”设置透明度。您可以通过输入 show Palette rgbformulae 找到调色板背后的公式。

以下示例创建一个绘图,其中包含 xrange[0:1]yrange[0:1] 中的随机点位置以及随机点大小(从 2 到 6) )和随机透明度(从 0x000xff)。颜色由 x 根据您的“手动调色板”确定。我希望您可以根据您的需要调整此示例。

代码:

### "manual" palette with transparency
reset session

# These are the rgb formulae behind palette 22,13,-22
set angle degrees
r(x) = 3*x-1 < 0 ? 0: (3*x-1 > 1) ? 1 : 3*x-1
g(x) = sin(180*x)
b(x) = 1-(3*x-1) < 0 ? 0: (1-(3*x-1) > 1) ? 1 : 1-(3*x-1)

set xrange [0:1]
set yrange[-0.1:1.1]

RandomSize(n) = rand(0)*4+2 # random size from 2 to 6
RandomTransp(n) = int(rand(0)*0xff)<<24 # random transparency from 0x00 to 0xff
myColor(x) = (int(r(x)*0xff)<<16) + (int(g(x)*0xff)<<8) + int(b(x)*0xff) + RandomTransp(0)

set samples 200
plot '+' u (x=rand(0)):(rand(0)):(RandomSize(0)):(myColor(x)) w p pt 7 ps var lc rgb var not

### end of code

结果:

enter image description here

关于Gnuplot:使用调色板时数据点的透明度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60250928/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com