Gnuplot可以实现可变透明度吗?

时间:2017-04-20 12:46:38

标签: gnuplot transparency gradient geometry

我想在Gnuplot中绘制一个实心圆,但透明度随着到圆心的距离而变化,即透明度渐变(靠近中心的实体,靠近圆的半径是透明的)。

I want something like this

有没有办法在Gnuplot中这样做?

提前谢谢!

2 个答案:

答案 0 :(得分:0)

一种选择是定义描述渐变的自定义函数(例如,高斯),然后使用pm3d map将其可视化:

set terminal pngcairo size 400,400
set output 'fig.png'

unset border
unset colorbox
unset xtics
unset ytics

set pm3d map

#force the plot to occupy the entire canvas
set lmargin at screen 0
set rmargin at screen 1
set tmargin at screen 1
set bmargin at screen 0

set isosamples 100,100

#specify custom palette
set palette model RGB
set palette defined ( 0 "white", 1 "royalblue" )

set xr [-10:10]
set yr [-10:10]

#a Gaussian might be a reasonable choice
splot exp(-0.2*(x*x+y*y))

然后产生:

enter image description here

定义函数的另一个选择可能是:

set xr [-pi:pi]
set yr [-pi:pi]
fn(r) = (r>(pi/2))?0:(cos(r))
splot fn(sqrt(x*x+y*y))

这会产生:

enter image description here

答案 1 :(得分:0)

试试这个:

set xrange [0:10]
set yrange [0:10]
do for [i=1:100] {
set style fill transparent solid i/100. noborder
set object circle at 5,5 radius 1.-i/100. fc rgb 'blue'
}
plot -1

enter image description here

并非所有终端都支持透明度;见help transparent。我用终端x11做了这个。