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

I use ListContourPlot to show exclusions in a physical parameter space. I have restrictions like A < 5 and B > 120. I also have data lists in the form of {{Input1, Input2, A, B, C, ...}, {Input,....}}. I create lists of triplets with the inputs as x and y coordinates and the interesting quantity as a third: AList = {{Input1, Input2, A}, {Input1, Input2, A}, ...}. Then I simply use ListContourPlot[AList, Contours -> {5}, ContourShading -> {None, Red}] to create a red shape that covers the excluded area. I do this e.g. in red and blue for A and B respectively. Then I use Show[LCP1, LCP2, ...] to overlay them into a single plot.

Now, it would be nice to also show the area that is excluded by A and B in a third color. Is there a possibility to create contours based on two criteria?

I manged to get what I want, by creating a list of elements that fulfill criterion A and then plot the exclusion for B the same way as above then doing it once over with a list of elements that fulfill criterion B and plot the exclusion for A. This is cumbersome, however, so I wonder whether it is possible to do it in one step.

share|improve this question
AList = {{Input1, Input2, A}, {Input1, Input2, A}, ...} doesn't reveal your intentions, I think – Dr. belisarius Apr 19 '13 at 12:28
I think I didn't really understand your question. Could you provide some minimal concrete data sample and code? – Silvia Apr 19 '13 at 16:44
up vote 2 down vote accepted

Perhaps you could interpolate your data and use RegionPlot:

(* example data *)
alist = Table[{x, y, (x + 2)^2 + y^2}, {x, -5, 5, 0.1}, {y, -5, 5, 0.1}]~Flatten~1;
blist = Table[{x, y, 15 (x - 2)^2 + 10 y^2}, {x, -5, 5, 0.1}, {y, -5, 5, 0.1}]~Flatten~1;

(* interpolation *)
afunc = Interpolation[alist];
bfunc = Interpolation[blist];

(* plotting *)
With[{a = afunc[x, y] < 5, b = bfunc[x, y] > 120}, 
 RegionPlot[{a, b, a && b}, {x, -5, 5}, {y, -5, 5}, PlotStyle -> {Red, Green, Blue}]]

enter image description here

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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