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

Pet*_*ok. 2 gradient gnuplot colors

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

颜色渐变底纹

the*_*ozh 5

我不知道 gnuplot 有渐变填充选项,但我可能是错的。以下是一个有点“丑陋”的解决方法。您基本上创建了 3 个相互重叠的图。您可能需要调整调色板以获得所需的颜色和平滑的过渡。

  1. 将调色板作为背景的虚拟图(即与图形一样大的颜色框)
  2. y>f(x)覆盖轴上方和y>0x2以及轴y<f(x)下方的部分。y<0x1
  3. 再次绘图f(x)以查看f(x)轴再次抽动

编辑: 使用的代码的早期版本multiplot。没必要,用就可以了set colorbox back。但 thenset 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
Run Code Online (Sandbox Code Playgroud)

结果:

在此输入图像描述