# problem with the 'Filling' command

Hello colleagues!!

I have an issue with the Filling parameter in a ListPlot. I constructed an equilateral triangle of length 1, where I plot some points in barycentric coordinates, describing a curve and a line when joined. Here's a view: For the model I'm describing, I need to fill with color the upper right region, inside the triangle, defined by a segment of the red line, a segment of the blue curve, and a segment of the right side of the triangle. The region seems like a right triangle, the hipotenuse being 'curve' (actually, the red line and the right side of the triangle are perpendicular).

I tried to use the Filling option of the ListPlot command, but I'm almost convinced that it's impossible to fill the described region using Filling. I'm currently working on another approach to put color in this region, but I think this could be a nice problem for anyone of you. Hats off for the one who can solve it, and thank you in advance!!

Daniel

PD: Here's some code to replicate the exact figure:

k1 = Table[0.01 i, {i, 0, 100}];
yLine = k1 Sqrt/2;
xLine = (Sqrt k1 + yLine)/Sqrt;
k3 = Table[
Solve[{x k1[[i]] == y 1/4, k1[[i]] + x + y == 1}, {x, y}], {i,
1, 101}][[All, 1]][[All, 1]][[All, 2]];
k4 = Table[
Solve[{x k1[[i]] == y 1/4, k1[[i]] + x + y == 1}, {x, y}], {i,
1, 101}][[All, 1]][[All, 2]][[All, 2]];
yCurve = k3 Sqrt/2;
xCurve = (Sqrt k4 + yCurve)/Sqrt;
leftSide = Table[Sqrt k1[[i]], {i, 1, 51}];
rightSide = Table[-Sqrt (k1[[i]] - 1), {i, 51, 101}];
bottomSide = Table[0, {i, 1, 101}];
ListPlot[{Transpose[{k1, bottomSide}],
Transpose[{k1[[1 ;; 51]], leftSide}],
Transpose[{k1[[51 ;; 101]], rightSide}], Transpose[{xLine, yLine}],
Transpose[{xCurve, yCurve}]}, AspectRatio -> Sqrt/2,
PlotRange -> {{0, 1}, {0, Sqrt/2}}, Joined -> True,
PlotStyle -> {Black, Black, Black, Red, Blue}]

• Welcome to Mathematica.SE! I suggest that: 1) You take the introductory Tour now! 2) When you see good questions and answers, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge. Also, please remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign! 3) As you receive help, try to give it too, by answering questions in your area of expertise. – bbgodfrey May 17 '15 at 16:35
• perhaps Filling -> {4 -> {{3}, {Blue, None}}, 4 -> {{5}, White}}? – kglr May 17 '15 at 17:40

lines = {{{0, 0}, {0, 1}}, {{0, 0}, {1/2, Sqrt/2}},
{{1/2, Sqrt/2}, {1, 0}}, {{0, 0}, {1, 1/2}}};
curve = Join @@ ({y + x /2, Sqrt x/2} /.
Table[Solve[{x k1[[i]] == y 1/4, k1[[i]] + x + y == 1}, {x, y}], {i, 1, 101}]);

ListLinePlot[{## & @@ lines, curve}, AspectRatio -> Sqrt/2,
PlotRange -> {{0, 1}, {0, Sqrt/2}},
PlotStyle -> {Black, Black, Black, Red, Blue},
Filling -> {4 -> {{3}, {Yellow, None}}, 4 -> {{5}, White}}] For non-white Background, change White to the background color:

ListLinePlot[{## & @@ lines, curve}, AspectRatio -> Sqrt/2,
PlotRange -> {{0, 1}, {0, Sqrt/2}},
PlotStyle -> {Black, Black, Black, Red, Blue}, Background -> Cyan,
Filling -> {4 -> {{3}, {Yellow, None}}, 4 -> {{5}, Cyan}}] • One might also choose to use Transparent instead of White for the fill if the background of the plot were not white. – J. M. will be back soon May 17 '15 at 18:17
• @Guesswhoitis., Transparent instead of White does not cover the piece we need to cover. To deal with non-white Background, we need to use the background color in place of White. – kglr May 17 '15 at 18:26
• Ah, after reading the docs for Filling I realized it now. Thanks for the correction! – J. M. will be back soon May 17 '15 at 18:28
• Thanks kguler, you did it!! :-) – cricricombowino May 18 '15 at 19:11
• @cricricombowino, my pleasure. Welcome to mma.se. – kglr May 18 '15 at 19:42