Gnuplot 5:曲线之间的颜色渐变阴影

Gnuplot 5: color gradient shading between curves

这是用 Matplotlib 创建的。是否可以在 Gnuplot 5 中制作相同类型的阴影?

我不知道 gnuplot 有渐变填充选项,但我可能是错的。 以下是一些 "ugly" 解决方法。您基本上在彼此之上创建了 3 个地块。您可能需要调整调色板以获得所需的颜色和平滑的过渡。

  1. 将调色板作为背景的虚拟图(即与图表一样大的颜色框)
  2. 覆盖y>f(x)y>0x2轴以及y<f(x)y<0x1轴以下的部分轴.
  3. 再次绘制 f(x) 以查看 f(x) 并再次绘制坐标轴

编辑: 早期版本的代码使用 multiplot。没必要,用set colorbox back就可以了。但是 set xzeroaxis ls -1 不再可见,请添加 plot 0 w l ls -1

代码:

### filled curve with gradient
reset session

f(x) = sin(x)/(1+x)
fabove(x) = f(x)<0 ? 0 : f(x)
fbelow(x) = f(x)>0 ? 0 : f(x)

set samples 200
set palette defined (0 "white", 1 "red", 2 "black")

set colorbox back user origin graph 0, graph 0 size graph 1, graph 1
unset cbtics

set xrange[0:15]
set xzeroaxis ls -1
set yrange[-0.2:0.5]

plot fabove(x) w filledcurves x2 fc rgb "white" not, \
     fbelow(x) w filledcurves x1 fc rgb "white" not, \
     f(x) w l lw 2 lc rgb "black", \
     NaN palette, \
     0 w l ls -1
### end of code

结果: