I'm plotting the graph below using the following code. The problem is that I need to make the area between the green and red curve shaded, but I can't make this work using Filling. I'd appreciate any ideas. (Have already tried the solution in here, which fails strangely because it only plots the left half of the red line)

    x = d;
y = d^2;
z = Max[0, 2 (d - 1/2)];
p1 = Plot[x, {d, 0, 1}, PlotLegends -> Placed[LineLegend[{
RGBColor[0.368417, 0.506779,
0.709798]}, {"Assignment by lottery"}], {0.282, 0.8}],
PlotStyle -> RGBColor[0.368417, 0.506779, 0.709798]];

p2 = Plot[y, {d, 0, 1}, PlotLegends -> Placed[LineLegend[{
RGBColor[0.560181, 0.691569,
0.194885]}, {"Complete equality"}], {0.25, 0.9}],
PlotStyle -> RGBColor[0.560181, 0.691569, 0.194885]];

p3 = Plot[z, {d, 0, 1}, PlotLegends -> Placed[LineLegend[{
RGBColor[0.922526, 0.385626, 0.209179]}, {"FCFS"}], {0.145, 0.7}],
PlotStyle -> RGBColor[0.922526, 0.385626, 0.209179]];

Show[{p2, p1, p3}, AxesLabel -> {F[t], Subscript[L, P][F[t]]},
LabelStyle -> Directive[{FontColor -> Black}, {FontSize -> 16}]]

• Please, post the code not an image. Commented May 27, 2020 at 6:32
• Filling->{2->{3}} Commented May 27, 2020 at 7:01
• Have you tried doing it all under a single Plot? (I'd try it myself, but without the code here as text, I can't try it out and modify it without manually retyping everything...that's why it's always useful to post code, not images of code! :) ) Commented May 27, 2020 at 7:59
• @yarchik Thank you, I now copy the code Commented May 27, 2020 at 23:08
• @thorimur Thank you. I now have copied the code instead of the image. The reason I didn't use a single plot is that I set different specifications for p1,p2,p3 plots, and I don't know how to do that in a single plot comment.. Commented May 27, 2020 at 23:11

Plot[{x, y, z}, {d, 0, 1}, Filling -> {3 -> {2}},
PlotLegends -> Placed[LineLegend @ {"Assignment by lottery", "Complete equality",
"FCFS"}, {0.35, 0.7}],
PlotStyle -> {RGBColor[0.368417, 0.506779, 0.709798],
RGBColor[0.560181, 0.691569, 0.194885],
RGBColor[0.922526, 0.385626, 0.209179]},
AxesLabel -> {F[t], Subscript[L, P][F[t]]},
LabelStyle -> Directive[{FontColor -> Black}, {FontSize -> 16}],
Exclusions -> None]


Use Filling -> {2 -> {3}} to get

• @kgir Thanks a lot! This is great. There's only one small issue: the legend font appears to be larger in the output of your code. Is there a way to reduce the font of the legend? (but not the font of the axes) Commented May 28, 2020 at 5:29
• @afshi7n, you can use PlotLegends -> Placed[LineLegend[{"Assignment by lottery", "Complete equality", "FCFS"}, LabelStyle -> 12], {0.35, 0.7}] (or use your desired fontsize in place of 12)
– kglr
Commented May 28, 2020 at 5:34
• Thank you so much Commented May 28, 2020 at 5:44