【发布时间】:2020-02-10 12:56:36
【问题描述】:
【问题讨论】:
【问题讨论】:
我不知道 gnuplot 有渐变填充选项,但我可能是错的。 以下是一个“丑陋”的解决方法。您基本上在彼此之上创建 3 个图。您可能需要调整调色板以获得所需的颜色和平滑的过渡。
y>f(x) 和y>0 上方到x2-axis 以及y<f(x) 和y<0 下方到x1-axis 的部分。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
结果:
【讨论】: