(Another) New approach with Dev version 5.5
The dev version has a new mechanism for masking
. Here we first create the filled area for the whole graph as image
, and then everything that is outside the desired area is masked, i.e. invisible. The masking area is a (complicated) polygon, which we have to construct in a two-step manner: First, the upper boundary is created in normal plotting direction as the larger value of the two data sets, then the lower boundary needs to be created in backwards direction as the minimum value, so that in the end a proper polygon is created. For illustration purposes I used the functions from @Christoph's answer and transformed them into a data set that should look like OP's data file:
set yrange[0:1]
set xrange[400:2500]
set ur [400:2500]
set vr [0:1]
set samples 1000
set isosamples 1000
fhot(x) = 0.1*exp(-((x-400)/200)**2) + 0.8*exp(-((x-2000)/300)**2)
fcold(x) = 0.25*exp(-((x-700)/100)**6)+ 0.4 - (2e-4*(x-2500))**2
set table $data
plot '+' u 1:(fhot($1)):(fcold($1)) w table
unset table
Now the upper and lower boundary are calculated:
set table $upper
plot $data u 1:($2>=$3 ? $2 : $3) w table
unset table
# gnuplot has no build-in "backwards" plotting
set table $lower
plot for [i=1:|$data|] $data every ::(|$data|-i)::(|$data|-i) u 1:($2<=$3 ? $2 : $3) w table
unset table
set table $mask
plot $upper w table
plot $lower w table
unset table
I found a fully opaque palette to be too much, therefore let's define a new, half-transparent one:
set palette defined (-1 "blue", 0 "white", 1 "red")
set colormap new MYPALETTE
do for [i=1:|MYPALETTE|] {MYPALETTE[i] = MYPALETTE[i] + (int(0.5*0xff)<<24)}
unset colorbox
Now in the actual plotting command the first element is the masking data, which doesn't plot anything by itself but prepares for the next elements of the plot:
plot $mask w mask not, '++' u 1:2:(fhot($1)-fcold($1)) mask w image fc palette MYPALETTE not, fhot(x) lc "red" lw 3, fcold(x) lc "blue" lw 3
