How can I fill the area between the curves? I cant seem to fill all three of them...
How about creating the filling and the plot separately and combining them later?
yf[x_] := -x^2 + 2;
yg[x_] := -x;
yh[x_] := x;
plot = Plot[{yf[x], yg[x], yh[x]}, {x, -2, 2}];
fill = RegionPlot[yf[x] > y && (yg[x] < y || yh[x] < y), {x, -2, 2}, {y, -2, 2},
PlotPoints -> 50,
MaxRecursion -> 3];
Show[fill, plot]
If you just want some kind of filling, you can just add from curve 1 to 3 as well:
Plot[{
-x^2 + 2,
-x,
x
},
{x, -2, 2},
Filling -> {1 -> {2}, 1 -> {3}}
]
The area above the yellow and green lines is darker because it's effective being filled twice. If you want the shading to be uniform, you can either use halirutan's answer, or you can specify a colour with no opacity as the filling:
Plot[{
-x^2 + 2,
-x,
x
},
{x, -2, 2},
Filling -> {1 -> {{2}, LightBlue}, 1 -> {{3}, LightBlue}}
]
yf[x_] := -x^2 + 2;
yg[x_] := -x;
yh[x_] := x;
Plot[{yf[x], yg[x], yh[x], Min[yg[x], yh[x]]}, {x, -2, 2},
PlotStyle -> {Automatic, Automatic, Automatic, None},
Filling -> {1 -> {4}}]
You can also use ParametricPlot
as follows:
ParametricPlot[{{x, v Min[yg[x], yh[x]] + (1 - v) yf[x]}, {x, yg[x]}, {x, yh[x]}},
{x, -2, 2}, {v, 0, 1},
Axes -> False, Exclusions -> None, BaseStyle -> Thick]