# How to use filling in ContourPlot

I want to fill region between different contours, e.g. ContourPlot[{c1 = f1, c2 = f2}, ...] a la the filling options for Plot like Filling -> {1->{2}}. Is it an easier way than superimposing two contour plots then manually excluding regions?

-
 I think some times it will not be so clear for implicit functions to say something analogous to Filling -> {1->{2}}. eg. ContourPlot[{Cos[x] + Cos[y] == 1/2, Sin[x] + Cos[y] == 1/2}, {x, 0, 12}, {y, 0, 12}]. btw maybe it will be RegionPlot what you are looking for. – Silvia Aug 5 '12 at 13:37

I think some times it will not be so clear for implicit functions to say something analogous to Filling -> {1->{2}} as it is in Plot. Anyway, maybe it will be RegionPlot what you are looking for. But in that case you might still need superimposing two Graphics.

Here is an example:

curvegraph =
ContourPlot[{Cos[x] + Cos[y] == 1/5, Sin[x] + Cos[y] == 1/10},
{x, 0, 4 Pi}, {y, 0, 4 Pi},
ContourStyle -> {Directive[Red, Thick], Directive[Blue, Thick]}];

RegionPlot[(Cos[x] + Cos[y] <= 1/5 &&
Sin[x] + Cos[y] >= 1/10) || (Cos[x] + Cos[y] >= 1/5 &&
Sin[x] + Cos[y] <= 1/10), {x, 0, 4 Pi}, {y, 0, 4 Pi},
PlotPoints -> 50, BoundaryStyle -> None,
PlotStyle -> Lighter[Orange, .9]];



-
It seems to be what the OP wanted, +1. – Artes Aug 5 '12 at 14:07
Awesome answer - almost what I wanted! I was hoping for a nice option since it does get tedious writing the conditions for RegionPlot. Thanks for the pointer to RegionPlot though; now I just need to cook some automating functions. – polyglot Aug 5 '12 at 14:13
@Artes Thanks :) I'm not sure what the OP exactly want. There could be many possibilities for implicit function curves.. – Silvia Aug 5 '12 at 14:14
@polyglot Thanks. Though it looks not so trivial for me to fill areas between free curves automaticly.. Maybe you could introduce some dynamic things to manually specify (eg. using mouse/Locators etc.) areas you want to fill. – Silvia Aug 5 '12 at 14:19
@polyglot thanks for accepting:) but maybe you would like to wait for some time to see if there are better answers from others :) And welcome to Mathematica.SE! – Silvia Aug 5 '12 at 14:23

It seems you would rather use RegionPlot instead of ContourPlot.

Let's define e.g.

f[x_] := x^2 - x y + y^2 - 3
g[x_] := x^2 + 5 x y - 3 y^2 - 2


then

ContourPlot[{f[x] == 2, g[x] == 3}, {x, -5, 5}, {y, -5, 5}]


or one could use ContourPlot this way :

ContourPlot[f[x] - 2, {x, -5, 5}, {y, -5, 5}, Contours -> 11,
RegionFunction -> Function[{x, y}, g[x] - 3 < 0]]


while

RegionPlot[{f[x] - 2 > 0, g[x] - 3 < 0}, {x, -5, 5}, {y, -5, 5}]


or extracting only regions between curves

GraphicsGrid[ Table[ RegionPlot[ a[g[x] - 3, 0] && b[f[x] - 2, 0], {x, -5, 5}, {y, -5, 5},
Axes -> True, BoundaryStyle -> {Thick, Darker @ Green}],
{a, {Greater, Less}}, {b, {Greater, Less}}]]


-
 +1, was just writing a same ting :) – Silvia Aug 5 '12 at 13:57 @Silvia Thanks, questions while not well posed are interpretable in many different ways, however interpretations are sometimes close enough. – Artes Aug 5 '12 at 14:03