# Filling between multivalued curve and normal curve

I have a multivalued curve p1 (left curve) and a normal curve xpr2 (right), and I want to fill the middle region between them as blue, and the rightmost region as red.

However, I get this extra filled part above my multivalued function, presumably because the xpr2 curve is above that part. Is there a way to get the plot to ignore filling beyond a certain point?

xpr1[y_] := 5.077959119860908 - 15.96152127464673 y^(1/3) + 11.632042032912723 Sqrt[y];
xpr2[x_] := 2.4673477623994344 - 1.8055789567179195 x + 0.5471986643936791 x^2 - 0.055509819604498495 x^3;
p1[y_] := {xpr1[y], y};
Plot[{xpr2[x], p1[y][] /. NSolve[p1[y][] == x]}, {x, 0, 2},
PlotRange -> {{0, 2}, {0.2, 1.2}},
Filling -> {1 -> {{2}, {Red, Blue}}}]


Result: And this is what I want it to look like: • Your function curves back on itself and filling in Plot is filling until it reaches the second plot. The filling meets the second plot outside of the plot range. You may have to use ParametricPlot or something like that. Nov 10, 2015 at 17:50

You can draw branches separately and choose the right filling

p1[y_] := {xpr1[y], y};
Plot[{p1[y][] /. NSolve[p1[y][] == x][],
p1[y][] /. NSolve[p1[y][] == x][], xpr2[x]}, {x, 0, 2}, PlotRange -> All,
Filling -> {3 -> {{1}, {Red, None}}, 1 -> {{2}, Blue}},
PlotStyle -> {ColorData[97, 1], ColorData[97, 1], ColorData[97, 2]}] • It is quite strange to see the filling artifacts (white pixels) under the top (blue) curve on your plot. I don't get these with version 10.3 on Win7 x64. What is you OS/version? Nov 10, 2015 at 20:52
• @AlexeyPopkov version 10.3 on Linux Nov 10, 2015 at 21:14
Show[{
RegionPlot[ y < xpr2[x] && x > xpr1[y] , {x, 0, 3}, {y, 0, 3},
PlotStyle -> Blue],
RegionPlot[ y > xpr2[x] && x > xpr1[y] , {x, 0, 3}, {y, 0, 3},
PlotStyle -> Red],
Plot[xpr2[x], {x, 0, 3}, PlotStyle -> Green],
ParametricPlot[{xpr1[y], y}, {y, 0, 3}, PlotStyle -> Black]
}, PlotRange -> {{0, 2}, {0, 3}}] If you don't clip the plot with PlotRange, you will see that the filling is exactly as you asked for it to be.

Plot[{xpr2[x], p1[y][] /. NSolve[p1[y][] == x]}, {x, 0, 2},
Filling -> {1 -> {{2}, {Red, Blue}}}]
` • See my edit please. Nov 10, 2015 at 19:10
• +1 Because I understood the same thing from the original post Nov 10, 2015 at 19:22