# How to shade the area bounded by more than 2 functions?

I am trying to shade the area bounded by the lines $y=2$, $y=-x+2$ and the parabola $y=x^2$. The plot is shown below. The area I'm talking about is the that bounded by the 4 black points. I am trying to shade it and I don't know how. Your assitance is appreciated.

Plot[{2 - x, x^2, 2}, {x, -3, 3}, PlotRange -> {-1, 5},
PlotStyle -> {{Red, Thick}, {Dashed}, {Blue, Thick}},
Epilog -> {Black, PointSize[0.025], Point[pts]}]


• Show[ RegionPlot[y < 2 && y < 2 - x && y > x^2, {x, -2, 2}, {y, -1, 3}], Plot[{2 - x, x^2, 2}, {x, -3, 3}]]
– Kuba
Oct 27 '14 at 23:45
• @Kuba Show[RegionPlot[Min[2, 2 - x] > y > x^2, {x, -2, 2}, {y, -1, 3}], Plot[{2 - x, x^2, 2}, {x, -3, 3}]] Oct 28 '14 at 0:06

pts = {{-Sqrt@2, 2}, {1, 1}, {0, 2}, {0, 0}};
opts = {PlotRange -> {-1, 5}, PlotStyle -> {{Red, Thick}, {Dashed}, {Blue, Thick}},
Epilog -> {Black, PointSize[0.025], Point[pts]},
Filling -> {3 -> {{2}, {Transparent, Lighter@Lighter@Blue}}}};
Show[
Plot[{2 - x, x^2, 2}, {x, -3, 0}, Evaluate@opts],
Plot[{2, x^2, 2 - x}, {x, 0, 3}, Evaluate@opts], PlotRange -> All]


Plot[{2 - x, x^2, 2}, {x, -3, 3}, PlotRange -> {-1, 5},
PlotStyle -> {{Red, Thick}, {Dashed}, {Blue, Thick}},
Prolog ->
First@Show@
BoundaryDiscretizeRegion[
ImplicitRegion[y <= 2 - x && y <= 2 && y >= x^2, {x, y}]]
]


Someday

BoundaryDiscretizeRegion[
ImplicitRegion[y <= 2 - x && y <= 2 && y >= x^2, {x, y}]]["GraphicsComplex"]


will work reliably.

• "some day" I'll have v10. +1 :) Oct 28 '14 at 0:00
Plot[{ConditionalExpression[x^2, x^2 <= Min[2, 2 - x]], Min[2, 2 - x],2 - x, 2, x^2}, {x, -3, 3},
Filling -> {1 -> {2}}, FillingStyle -> Yellow,
PlotStyle -> {Directive[{Opacity[1], Yellow}], Opacity[0],
Directive[{Opacity[1], Red}], Green, Directive[{Dashed, Orange}]}, BaseStyle -> Thick]


Use MeshFunctions and Mesh to add the intersection points

Plot[{ConditionalExpression[x^2, x^2 <= Min[2, 2 - x]], Min[2, 2 - x],
2 - x, 2, x^2}, {x, -3, 3},
Filling -> {1 -> {2}}, FillingStyle -> Yellow,
Mesh -> {{0}, {0}}, MeshStyle -> PointSize[.03],
MeshFunctions -> {# &, ConditionalExpression[Min[2, 2 - #] - #^2, #2 + # <= 2 && #2 <= 2] &},
PlotStyle -> {Directive[{Opacity[1], Yellow}], Opacity[0],
Directive[{Opacity[1], Red}], Green, Directive[{Dashed, Orange}]},
BaseStyle -> Thick]


ParametricPlot[{ConditionalExpression[{x, v x^2 + (1-v) Min[2, 2 - x]}, x^2 <= Min[2, 2 - x]],
{x, 2 - x}, {x, 2}, {x, x^2}}, {x, -3, 3}, {v, 0, 1},
AspectRatio -> 1/GoldenRatio, PlotStyle -> ColorData[1, "ColorList"],
BaseStyle -> Thick, Frame -> False, Axes -> True, Mesh -> None]


• Perhaps if you put the ConditionalExpression first its boundaries will be overwritten by the other plots, instead of the other way around. Oct 28 '14 at 0:21
• Thank you @Michael, very good point.
– kglr
Oct 28 '14 at 0:32
pts = {{-Sqrt@2, 2}, {1, 1}, {0, 2}, {0, 0}};
prolog = Plot[{x^2, Piecewise[{{2 - x, x > 0}, {2, x < 0}}]},
{x, -Sqrt@2, 1}, Filling -> {1 -> {2}}][[1]];


I have applied prolog with Piecewise

Plot[{2 - x, x^2, 2}, {x, -3, 3}, PlotRange -> {-1, 5},
PlotStyle -> {{Red, Thick}, {Dashed}, {Blue, Thick}},
Prolog -> prolog,
Epilog -> {Black, PointSize[0.025], Point[pts]}
]