Gnuplot 5:曲线之间的颜色渐变阴影
Gnuplot 5: color gradient shading between curves
这是用 Matplotlib 创建的。是否可以在 Gnuplot 5 中制作相同类型的阴影?
我不知道 gnuplot 有渐变填充选项,但我可能是错的。
以下是一些 "ugly" 解决方法。您基本上在彼此之上创建了 3 个地块。您可能需要调整调色板以获得所需的颜色和平滑的过渡。
- 将调色板作为背景的虚拟图(即与图表一样大的颜色框)
- 覆盖
y>f(x)
和y>0
至x2
轴以及y<f(x)
和y<0
至x1
轴以下的部分轴.
- 再次绘制
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
结果:
这是用 Matplotlib 创建的。是否可以在 Gnuplot 5 中制作相同类型的阴影?
我不知道 gnuplot 有渐变填充选项,但我可能是错的。 以下是一些 "ugly" 解决方法。您基本上在彼此之上创建了 3 个地块。您可能需要调整调色板以获得所需的颜色和平滑的过渡。
- 将调色板作为背景的虚拟图(即与图表一样大的颜色框)
- 覆盖
y>f(x)
和y>0
至x2
轴以及y<f(x)
和y<0
至x1
轴以下的部分轴. - 再次绘制
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
结果: