# Plot between multiple curves

I have three functions, U1, U2, Dead. I would like to fill the area between the three curves when U2 is (only) above both U1 and Dead. This raises two issues relative to what I can find online. One is dealing with three vs. two curves filling and one is that the filling ends up only on a region. (I can find some things online on the latter---but I need a solution that works with the three curves.)

To be more specific: the functions are

U1[del_] = (1 - del)/del
U2[del_] = del
Dead[del_] = del*del*del


and right now I have

Plot[{U1[del], U2[del], Dead[del]},
{del, 0, 1},
PlotRange -> {0, 1},
PlotStyle -> {{Blue, Dashed, Thick}, {Red, Dashed, Thick}, {Green, Dashed, Thick}},
Filling -> {2 -> {3}},
Frame -> True]


This filled between U2 and Dead. But I want the filling to be between U2 and Max[U1, Dead] and only when U2 is above the max.

Any help would be appreciated. Apologies if I am writing in the wrong format---I am new. Thanks!

## 2 Answers

I strongly applaud Dr. belisarius' use of an invisible curve to control the filling, but I think the following implementation of his idea is easier to understand.

U1[del_] := (1 - del)/del
U2[del_] := del
Dead[del_] := del^3

controlCurve[del_] :=
Piecewise[
{{U2[del], U1[del] > U2[del]},
{U1[del], U1[del] > Dead[del]}},
Dead[del]]

Plot[{U1[del], U2[del], Dead[del], controlCurve[del]}, {del, 0, 1},
PlotRange -> {0, 1},
PlotStyle ->
{{Blue, Dashed, Thick}, {Red, Dashed, Thick},
{Green, Dashed, Thick}, Transparent},
Filling -> {2 -> {{4}, Yellow}},
Frame -> True]


• thanks m_goldberg---indeed this is easier to understand! – Amanda Mar 8 '16 at 23:46
• C'est véritablement utile puisque c'est joli. – Dr. belisarius Mar 9 '16 at 3:15
f[s_] := Plot[{U1[del], U2[del], Dead[del],
If[s[U2[del], #], #, U2[del]] &@Max[U1[del], Dead[del]]},
{del, 0, 1}, PlotRange -> {0, 1},
PlotStyle -> {{Blue, Dashed, Thick},
{Red, Dashed, Thick},
{Green, Dashed, Thick},
Transparent},
Filling -> {2 -> {4}}, Frame -> True]

f /@ {Less, Greater}


• thanks! this is awesome! i appreciate it! – Amanda Mar 8 '16 at 18:34
• May I bother you with a follow up: Would it be possible to explain the role of the "#" in this bit: If[s[U2[del], #], #, U2[del]] &@Max[U1[del], Dead[del]]}? Just want to understand/learn. Thanks again! – Amanda Mar 8 '16 at 22:05