# How to fill a specific region in a plot?

I am having troubles in fillng a particular region in a plot. I'm trying ot use Mathematica to plot the same image I linked below, and this is ok (except for all the numbers/letters labeling but this is not important).

What I have troubles with, is how to fill the region below the $$x$$-axis but above the green curve.

And again, I would also know how instead fill the entire region above the green curve, but under the parabola. I tried many combination of the filling code but no results.

Thank you!

• Please provide your code (copy and paste-able InputForm) for a minimal working example. Dec 19, 2022 at 20:00

One way is using RegionPlot to add such region.

Clear[f, g, plot, reg];
f[x_] = 4 + 1/16 (-9 - 4 Sqrt[5]) (-19 + 8 Sqrt[5] + x)^2;
g[x_] = Log[5, x + 2] - 1;
plot = Plot[{f[x], g[x]}, {x, -2.5, 4.5},
PlotStyle -> {Darker@Cyan, Darker@Green}, AspectRatio -> Automatic];
reg = RegionPlot[{g[x] <= y <= f[x] && y <= 0}, {x, -2, 3}, {y, -2,
0}, PlotStyle -> LightRed, BoundaryStyle -> None];
Show[reg, plot, PlotRange -> {-4, 4}, AxesStyle -> Arrowheads[{0.05}],
Axes -> True, Frame -> False,
GridLines -> {{{-2, {Thick, AbsoluteDashing[{3, 3}]}}}, None},
Epilog -> {{AbsoluteDashing[3, 3], Line[{{-1, -1}, {-1, 0}}],
Line[{{-1, -1}, {0, -1}}]}}]


• This is so aesthetically pleasing. Thank you! Dec 20, 2022 at 8:55
Clear["Global*"]

f1[x_] = -1 (2 x - 3) (x + 1);
f2[x_] = Log[(3 x + 6)/10];

plt = Plot[{f1[x], f2[x]}, {x, -3, 4},
PlotRange -> {-5, 5}];


The intersections of the curves are

arg = Solve[{f1[x] == f2[x], -3/2 < x < 2}, x];

rng = LessEqual @@ Insert[x /. arg, x, 2];

f3[x_] = ConditionalExpression[f2[x], rng];

f4[x_] = ConditionalExpression[Min[f1[x], 0], rng];

Plot[{f1[x], f2[x], f3[x], f4[x]}, {x, -3, 4},
Filling -> 3 -> {4},
FillingStyle -> Lighter[ColorData[97][2], 0.7],
PlotRange -> {-5, 5},
PlotStyle -> {ColorData[97][1], ColorData[97][2],
Opacity[0], Opacity[0]},
PlotLegends -> Placed[
{f1[x], f2[x], None, None},
{0.8, 0.7}],
AxesLabel -> (Style[#, 14] & /@ {x, f})]


As you did not specify any functions, therefore I choose something similar:

f1[x_] = -1 (2 x - 3) (x + 1);
f2[x_] = Log[(3 x + 6)/10];


To fill from f1 to the axis:

Plot[{f1[x], f2[x]}, {x, -3, 4}, PlotRange -> {-5, 5},
Filling -> {2 -> 0}]


And to fill from f2 to f1:

Plot[{f1[x], f2[x], f3[x]}, {x, -3, 4}, PlotRange -> {-5, 5},
Filling -> {2 -> {1}}]


A fill from the axis down to f2 can be done with an auxillary function:

f3[x_] = If[Re@f2[x] < 0, 0, f2[x]]
Plot[{f3[x], f1[x], f2[x]}, {x, -3, 4}, PlotRange -> {-5, 5},
Filling -> {1 -> {3}}]


For filling only inside f1, chnage the auxillary function and f2 because of the pole:

f2[x_] = Log[(3 x + 6.1)/10];
f3[x_] = If[f1[x] <= Re@f2[x], f2[x], If[Re@f2[x] < 0, 0, f2[x]]]
Plot[{f3[x], f1[x], f2[x]}, {x, -3, 4}, PlotRange -> {-5, 5},
Filling -> {1 -> {3}}]
`

• This is good! In the first one, how to fill only the region below $x$-axis but above the orange curve? I mean the little region contained from $-1$ ish to $1.5$? And in the second one, only the region betweel the orange curve and the parabola, between $-1$ ish and $1.5$? Dec 19, 2022 at 20:32
• I added this case. Dec 19, 2022 at 21:01
• Thank you for the work! But I actually meant only the small region inside the parabola, and above the green curve. Sorry for all this trouble! Dec 19, 2022 at 21:15
• I added this, but I think you should start doing something yourself. Otherwise you shall never learn Mathematica Dec 20, 2022 at 8:46
• I tried a lot but I failed in what I wanted. And again, neither the last case you showed is what I wanted. I thank you really much for all the efforts, I learnt two new things from your answer though. I will keep learning, for sure! Dec 20, 2022 at 8:57