关于在 pdf 终端下绘制波段的 Gnuplot 问题

Gnuplot problem about plotting band under pdf terminal

这是我的名为“DATA”的数据文件:

1   10  20  15  25
2   20  30  25  35
3   30  40  35  45
4   40  50  45  55

这是我的代码:

set term pdf enh solid color
set style fill transparent solid 0.3 noborder

datafile = "DATA"

set output "Output.pdf"

set xrange [1:4]
set yrange [0:60]

set xtics format "%.1f" 
set ytics format "%.0f"

plot 'DATA' using 1:2:3 notitle w filledcurves lc "purple", \
     'DATA' using 1:4:5 notitle w filledcurves lc "purple"

然后问题就来了。虽然我将两个波段的颜色都设置为“紫色”,但它们仍然显示出比两个波段重叠的紫色更深的不同颜色。如图所示:Output Picture。而这正是我不想要的。我想要一个具有一种统一颜色的加色带。

但如果我只是将终端从 pdf 更改为 post 或其他,我将不会得到带有透明线的图像。(我将在图片中绘制其他内容,因为上面的代码是简化的一)因为它似乎 post 终端不支持透明度。

那么我可以对这个问题提出建议吗?万分感谢!!

以下示例适用于您的第二种情况,但可能不是一般情况。根据数字,您可能需要计算波段的交点,这需要一些额外的工作。 也许有更聪明的方法来找到 4 个数字的最小值和最大值。 查看两个版本的对比。

代码:

### plot transparent additive bands
reset session

$Data <<EOD
1 10 20  0 10
2 20 30 15 25
3 30 40 30 40
4 40 50 45 55
EOD

Min4(a,b,c,d) = a<=b && a<=c && a<=d ? a : b<=c && b<=d ? b : c<=d ?  c : d
Max4(a,b,c,d) = a>=b && a>=c && a>=d ? a : b>=c && b>=d ? b : c>=d ?  c : d

set style fill transparent solid 0.3 noborder
unset key

set multiplot layout 1,2
    plot $Data u 1:2:3 w filledcurves lc "purple", \
            '' u 1:4:5 w filledcurves lc "purple"

    plot $Data u 1:(Min4(,,,)):(Max4(,,,)) w filledcurves lc "purple"
unset multiplot
### end of code

结果: