# ColorFunction as an interpolating function in a RegionPlot

I would like to fill a region below a curve using shading that represents a function (i.e. not just be filled in one solid color). Here is a working example.

(a system of ODEs, parameters and their solver)

eX[X_, Y_] := \[Rho] X - \[Beta] X Y - \[Mu] X
eY[X_, Y_] := \[Beta] X Y - \[Mu] Y
parms = {\[Beta] -> 0.002 , \[Rho] -> 0.27, \[Mu] -> 0.25  };

sys = {X'[t] == eX[X[t], Y[t]], Y'[t] == eY[X[t], Y[t]],
X == 1000, Y == 1};
tmax = 400;
sol = NDSolve[sys /. parms, {X, Y}, {t, 0, tmax}];


(interpolating functions)

Xfn = Flatten[{X} /. sol];
Yfn = Flatten[{Y} /. sol];


(plot - curve is a sum of the two functions)

RegionPlot[{y < Evaluate[Xfn[][t] + Yfn[][t]]}, {t, 0, 50},
{y, 0, 1200}, ColorFunction -> Function[{t, y}, t]]


I would like the shading under the curve to change as a function of this ratio:

Yfn/(Xfn+Yfn)

I'm assuming that this means changing "Function[{t,y},t]" in ColorFunction to include the function (above) of the ratio, probably in the place of the first t. However, I just can't figure it out. Thanks in advance. • ColorFunction -> Function[{t, y}, Yfn[][t]/(Xfn[][t] + Yfn[][t])] but that doesn't show much details (see also Plot[Yfn[][t]/(Xfn[][t] + Yfn[][t]), {t, 0, 50}]). Oct 26 '16 at 9:00

Using Blend. Apologies if I have misunderstood.

rp = RegionPlot[{y < Evaluate[Xfn[][t] + Yfn[][t]]}, {t, 0,
50}, {y, 0, 1200},
ColorFunction ->
Function[{t, y},
Blend[{Red, Green}, Yfn[][t]/(Xfn[][t] + Yfn[][t])]],
ColorFunctionScaling -> False];
f = Plot[1000 Yfn[][t]/(Xfn[][t] + Yfn[][t]) - 1200, {t, 0,
50}, ColorFunction ->
Function[{t, y},
Blend[{Red, Green}, Yfn[][t]/(Xfn[][t] + Yfn[][t])]],
ColorFunctionScaling -> False, Frame -> True];
Show[rp, f, PlotRange -> {-1200, 1200},
FrameTicks -> {Automatic, Range[0, 1000, 500]}] • Perfect! that worked wonderfully! Thanks. Oct 26 '16 at 16:28