# Finding the common areas of two contourplots

I used ListContourPlot to specify an area for which the function value is less than a number. For example consider the following areas:

 plot1 = ListContourPlot[
Table[Sin[i + j^2], {i, 0, 3, 0.1}, {j, 0, 3, 0.1}],
RegionFunction -> Function[{x, y, z}, z < 1], PlotRange -> {0, 1},
DataRange -> {{0, 3}, {0, 3}}]

plot2 = ListContourPlot[
Table[Cos[i + j^2], {i, 0, 3, 0.1}, {j, 0, 3, 0.1}],
RegionFunction -> Function[{x, y, z}, z < 0.7]
, PlotRange -> {0, .7}, DataRange -> {{0, 3}, {0, 3}},
ColorFunction -> ColorData["BlackBodySpectrum"]]


How can I specify the common areas of these two parameter spaces in a plot?

RegionPlot doesn't give the common area:

RegionPlot[
Sin[i + j^2] < 1 && Cos[i + j^2] < 0.7, {i, 0, 3}, {j, 0, 3},
PlotPoints -> 80, Mesh -> 2,
ColorFunction ->
Function[{x, y}, ColorData["SolarColors"][Sin[x^2 + y]]],
PlotRange -> {0, 2},
MeshFunctions -> {Sin[#1^2 + #2] &, Abs@Cos[#1^2 + #2] &}]


Because RegionPlot uses i and j which change continuously but ListContourPlot uses only certain number of data:

{i, 0, 3, 0.1}, {j, 0, 3, 0.1}

-
@cormullion: RegionPlot doesn't give me what I have in my mind.Please see the comment below. –  Soodeh Z. May 1 '13 at 10:15
Although some people have answered, which indicates they think they know what you have in mind, this question has some striking ambiguities. Perhaps if you were to explain what you mean by "parameter spaces" and how the "common areas" are defined you might get some responses that are closer to what you're looking for. For instance, is an "area" a geometric region, a rectangular extent, or is it perhaps a number representing its area? Are the "parameter spaces" the ranges of X and Y values shown in your plot or are they something else that needs to be derived from your input? –  whuber May 1 '13 at 16:29
@whuber I confess to guessing at what I thought the question was about...but I live surrounded by vagueness and ambiguity and have gotten too used to it. :) –  cormullion May 1 '13 at 21:16

plot1 = ListContourPlot[
Flatten[Table[{i, j, Sin[i + j^2]}, {i, 0, 3, 0.1}, {j, 0, 3, 0.1}], 1],
RegionFunction -> Function[{x, y, z}, z < 1/2]];
plot2 = ListContourPlot[
Flatten[Table[{i, j, Cos[i + j^2]}, {i, 0, 3, 0.1}, {j, 0, 3, 0.1}], 1],
RegionFunction -> Function[{x, y, z}, z < 0.7]];
plot3 = RegionPlot[Sin[i + j^2] < 1/2 && Cos[i + j^2] < 0.7, {i, 0, 3}, {j, 0, 3}];

GraphicsRow@{plot1, plot2, plot3}


-
You seem to have fixed the original plots too...:) –  cormullion May 1 '13 at 15:46
@cormullion They were in need :=) –  belisarius May 1 '13 at 15:47
So that's why I found it difficult to get my plot to look like the OP's... –  cormullion May 1 '13 at 16:13
@belisarius: Thanks a lot for your help. –  Soodeh Z. May 1 '13 at 16:58

You could try a RegionPlot:

RegionPlot[
Sin[i^2 + j] > 0 && Abs@Cos[i^2 + j] < 0.7, {i, 0, 3}, {j, 0, 3},
PlotPoints -> 80,
Mesh -> 2,
ColorFunction ->
Function[{x, y}, ColorData["SolarColors"][Sin[x ^2 + y]]],
MeshFunctions -> {Sin[#1 ^2 + #2] &, Abs@Cos[#1 ^2 + #2] &}]


This isn't quite the same as a combination of the original plots, though, so you'll need to experiment:

-
But RegionPlot is not the one I want: compare plot1 and RegionPlot[Sin[i + j^2] < 1, {i, 0, 3}, {j, 0, 3}]. They differ because ListContourPlot only consider the points {i, 0, 3, 0.1}, {j, 0, 3, 0.1} but RegionPlot, plot an area by considering i and j changes continuously. –  Soodeh Z. May 1 '13 at 10:13
@soodeh No problem, I'm sure there will be other answers... –  cormullion May 1 '13 at 10:22

Another way (I think in this way only a certain number of data are used for regionplot but I'm not sure about it):

sindata = Table[{i, j, Sin[i + j^2]}, {i, 0, 3, 0.1}, {j, 0, 3, 0.1}]~Flatten~1;
cosdata = Table[{i, j, Cos[i + j^2]}, {i, 0, 3, 0.1}, {j, 0, 3, 0.1}]~Flatten~1;

sinfunc = Interpolation[sindata];
cosfunc = Interpolation[cosdata];

With[{a = sinfunc[i, j] < 1/2, b = cosfunc[i, j] < .7},
RegionPlot[{a && b}, {i, 0, 3}, {j, 0, 3},PlotStyle -> {Blue}]]


-