Filling Between Curves [duplicate]

This question already has an answer here:

I want to fill in the region between the curves.

So far I have this:

Plot[{x + 7, 9 - x^2}, {x, 0, 1.5}, Filling -> {1 -> {2}}]


But I want something like this:

-

marked as duplicate by Mr.Wizard♦Jan 10 '14 at 10:26

So what's the logic here? 1) Fill to the left of the point of intersection? 2) Fill when curve 2 is above curve 1? 3) Fill the first enclosure between the two curves? – R. M. Sep 27 '13 at 19:26
@rm-rf I closed this question because as it has been interpreted it is a duplicate, and I wish to respect the older, original question from a contributing member. However, that makes the answers here somewhat harder to find. Do you think this might be a case where a merge is appropriate? I believe the original can be modified so that all the answers make sense. – Mr.Wizard Jan 10 '14 at 10:28
@Mr.Wizard Why does it make this harder to find? Duplicates show up exactly as any other post and are just as searchable/rep-earnable. It's only the "answerless duplicates" that are automatically redirected. But I agree that a merge might not be all that bad (esp. since only belisarius has an answer there), and Anon has an apparently general version of a shading function... – R. M. Jan 10 '14 at 16:10
@rm-rf I meant somewhat harder to find than if the close went the other way. Since you agree this is a good candidate for a merge, e.g. there is no Accepted answer here, I shall do that tomorrow unless you do it first. – Mr.Wizard Jan 10 '14 at 16:50

Alternatively, you can use the +/- option of Filling

Plot[{x + 7, 9 - x^2}, {x, 0, 1.5}, Filling -> {1 -> {{2}, {LightBlue, White}}}]


-
I would use None not White. – rcollyer Sep 27 '13 at 19:34
@rcollyer While I'm changing the colors, do you know off hand what the default blue is? – bobthechemist Sep 27 '13 at 19:37
The simplest way to get that color is to run, ColorData[1][1]. Then fiddle with the Opacity until you're content. – rcollyer Sep 27 '13 at 19:38
@bobthechemist Your answer was a few seconds before. I was late while extracting the default color from Plot[...]//InputForm :) – ybeltukov Sep 27 '13 at 19:47
No need to extract any color... just use Automatic :) – R. M. Sep 27 '13 at 19:50
Plot[{x + 7, 9 - x^2}, {x, 0, 1.5},
Filling -> {1 -> {{2}, {{Opacity[0.2], Hue[0.67, 0.6, 0.6]}, None}}}]


Update: you can use Automatic instead of {Opacity[0.2], Hue[0.67, 0.6, 0.6]}.

-

It's like rm-rf says in his comments, it's not really clear what the logic is. There are already plenty of ways to use Filling to produce the requested plot but here's a more general function to facilitate arbitrary logic:

shadeBoundedArea[plot_, region_] := Module[{rangex, rangey},
{rangex, rangey} = PlotRange /. AbsoluteOptions[plot];
Show[
plot,
RegionPlot[region, Evaluate@{x, Sequence @@ rangex},
Evaluate@{y, Sequence @@ rangey}]
]
]

Clear[x, y];

p = Plot[{f1[x], f2[x]}, {x, 0, 1.5}]

shadeBoundedArea[p, f1[x] < y < f2[x]]


-

Since Filling shades between two curves in the plot, add an extra curve that serves as the limit.

Plot[{Max[x + 7, 9 - x^2], x + 7, 9 - x^2}, {x, 0, 1.5}, Filling -> {1 -> {2}}]

-