要填充曲线下方的部分,您必须使用filledcurves
样式。使用该选项x1
填充曲线和 x 轴之间的部分。
为了只填充曲线的一部分,您必须过滤数据,即如果 x 值1/0
超出所需范围,则为(无效数据点)值,否则为数据文件中的正确值。最后绘制曲线本身:
set style fill transparent solid 0.35 noborder
filter(x,min,max) = (x > min && x < max) ? x : 1/0
plot 'data' using (filter($1, -1, -0.5)):2 with filledcurves x1 lt 1 notitle,\
'' using (filter($1, 0.2, 0.8)):2 with filledcurves x1 lt 1 notitle,\
'' using 1:2 with lines lw 3 lt 1 title 'curve'
这填充了范围[-1:0.5]
和[0.2:0.8]
。
举一个工作示例,我使用特殊的文件名+
:
set samples 100
set xrange [-2:2]
f(x) = -x**2 + 4
set linetype 1 lc rgb '#A3001E'
set style fill transparent solid 0.35 noborder
filter(x,min,max) = (x > min && x < max) ? x : 1/0
plot '+' using (filter($1, -1, -0.5)):(f($1)) with filledcurves x1 lt 1 notitle,\
'' using (filter($1, 0.2, 0.8)):(f($1)) with filledcurves x1 lt 1 notitle,\
'' using 1:(f($1)) with lines lw 3 lt 1 title 'curve'
结果(4.6.4):

如果您必须使用某种平滑,过滤器可能会对数据曲线产生不同的影响,具体取决于过滤的部分。您可以先将平滑数据写入临时文件,然后将其用于“正常”绘图:
set table 'data-smoothed'
plot 'data' using 1:2 smooth bezier
unset table
set style fill transparent solid 0.35 noborder
filter(x,min,max) = (x > min && x < max) ? x : 1/0
plot 'data-smoothed' using (filter($1, -1, -0.5)):2 with filledcurves x1 lt 1 notitle,\
'' using (filter($1, 0.2, 0.8)):2 with filledcurves x1 lt 1 notitle,\
'' using 1:2 with lines lw 3 lt 1 title 'curve'