I have a plot where several lines and curves intersect, and the regions between them are filled with red and blue. My code is
f[x_] = 2/(1 - 2 x^2); g[x_] = -(2/(1 + 2 x^2));
p1 = Plot[{g[x], -2}, {x, -2, -(1/Sqrt[2])},
PlotStyle -> ColorData[97, "ColorList"][[1]],
Filling -> {1 -> {2}}, FillingStyle -> {Blue, Opacity[0.5]}];
pa = Plot[{g[x], -2}, {x, -2, -(1/Sqrt[2])},
PlotStyle -> {Black, Black}];
p2 = Plot[{g[x], -2}, {x, -(1/Sqrt[2]), 1/Sqrt[2]},
Filling -> {1 -> {2}}, FillingStyle -> {Blue, Opacity[0.5]},
PlotStyle -> ColorData[97, "ColorList"][[1]]];
pb = Plot[{g[x], -2}, {x, -(1/Sqrt[2]), 1/Sqrt[2]},
PlotStyle -> {Black, Black}];
p3 = Plot[{g[x], -2}, {x, 1/Sqrt[2], 2}, Filling -> {1 -> {2}},
FillingStyle -> {Blue, Opacity[0.5]},
PlotStyle -> ColorData[97, "ColorList"][[1]]];
pc = Plot[{g[x], -2}, {x, 1/Sqrt[2], 2},
PlotStyle -> {Black, Black}];
p4 = Plot[{2, f[x]}, {x, -2, -(1/Sqrt[2])},
Filling -> {1 -> {{2}, LightRed}},
PlotStyle -> ColorData[97, "ColorList"][[1]]];
pd = Plot[{2, f[x]}, {x, -2, -(1/Sqrt[2])},
PlotStyle -> {Black, Black}];
p5 = Plot[{f[x], 2}, {x, -(1/Sqrt[2]), 1/Sqrt[2]},
Filling -> {1 -> {{2}, LightRed}},
PlotStyle -> ColorData[97, "ColorList"][[1]]];
pe = Plot[{f[x], 2}, {x, -(1/Sqrt[2]), 1/Sqrt[2]},
PlotStyle -> {Black, Black}];
p6 = Plot[{2, f[x]}, {x, 1/Sqrt[2], 2},
Filling -> {1 -> {{2}, LightRed}},
PlotStyle -> ColorData[97, "ColorList"][[1]]];
pf = Plot[{2, f[x]}, {x, 1/Sqrt[2], 2}, PlotStyle -> {Black, Black}];
line1 = Line[{{-(1/Sqrt[2]), -6}, {-(1/Sqrt[2]), 6}}];
line2 = Line[{{1/Sqrt[2], -6}, {1/Sqrt[2], 6}}];
It's horrible to look at, I know. It returns a nice plot though. What I would like to add to it are plot legends, as the red and blue regions indicate specific things. Can anyone help me?
Show
inLegended
$\endgroup$