Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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}}]

enter image description here

But I want something like this:

enter image description here

share|improve this question

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

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

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}}}]

Mathematica graphics

share|improve this answer
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}}}]

enter image description here

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

share|improve this answer

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];
   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]]

enter image description here

share|improve this answer

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}}]
share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.