本文介绍了Gnuplot:使用调色板时数据点的透明度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用调色板时是否可以绘制透明数据点?

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

我目前有以下代码:

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

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

My feeling is that transparency is overwritten by the arguments of the plot command.

推荐答案

如果您查看帮助调色板,您将找不到(或我忽略了)关于调色板透明度的声明。看来您可以用不同的方式为 RGB 设置调色板,但不能为 ARGB 设置调色板(A = alpha通道透明度)。因此,我假设调色板不可能具有透明度(如果我错了,请纠正我)。
作为解决方法,您必须通过手动设置透明度来设置颜色。
您可以通过键入 showpalette rgbformulae 查找调色板背后的公式。

If you check help palette you will not find (or I overlooked) a statement about transparency in the palette. It looks like you can set the palette in different ways for RGB, but not for ARGB (A=alpha channel for transparency). So, I assume it is not possible with palette to have transparency (please correct me if I am wrong).As workaround you have to set your transparency "manually" by setting the color with some transparency.You can find the formulae behind the palettes by typing show palette rgbformulae.

以下示例创建在 xrange [0:1] yrange [0:1] 中具有随机点位置且随机点大小的图(从2到6)和随机透明度(从 0x00 0xff )。颜色由 x 根据您的手动调色板确定。希望您可以根据需要调整此示例。

The following examples creates a plot with random point positions in xrange[0:1] and yrange[0:1] and random points size (from 2 to 6) and random transparency (from 0x00 to 0xff). The color is determined by x according to your "manual palette". I hope you can adapt this example to your needs.

代码:

### "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

结果:

这篇关于Gnuplot:使用调色板时数据点的透明度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-09 17:40