【问题标题】:Variable transparency is possible in Gnuplot?在 Gnuplot 中可以实现可变透明度吗?
【发布时间】:2017-04-20 12:46:37
【问题描述】:

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

在 Gnuplot 中有什么方法可以做到这一点吗?

提前谢谢你!

【问题讨论】:

    标签: gnuplot transparency gradient geometry


    【解决方案1】:

    一种选择是定义一个描述梯度的自定义函数(例如,高斯),然后使用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))
    

    这会产生:

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

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

    这会产生:

    【讨论】:

      【解决方案2】:

      试试这个:

      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
      

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

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2021-04-23
        • 1970-01-01
        • 2011-04-22
        • 2011-06-24
        • 2012-08-11
        • 2011-09-10
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多