Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

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

For a function I am plotting I can get a RegionPlot[f[x, y] > 100] but if I do ContourPlot[f[x, y], Contours -> {1, 10, 100, 1000}] in the same $x$ and $y$ ranges, only the contours for 1 and 10 are drawn, not the ones for 100 and 1000. I know that these two contours exists because RegionPlot finds them, so, what options of ContourPlot should I use to get the plot done?

For an example please try ContourPlot[0.000157223 10^(2 x - 2 y), {x, -6, -1}, {y, -6, -1}, Contours -> { 100}, ContourShading -> False]

share|improve this question
2  
So, um, can I see what f looks like? :-) – Jason is no longer a postdoc Mar 24 at 16:01
    
try PlotPoints – george2079 Mar 24 at 16:02
    
@JasonB The specific f I have today is something you do not want to look at :) it comes from a long manipulation of inputs. – Roberto Franceschini Mar 24 at 16:07
1  
Roberto, as you can see, we are shooting blind here. We need to have access to the function, or even better, to a minimal working example that exhibits the same problem, to provide meaningful help. – MarcoB Mar 24 at 16:15
1  
Interestingly, ContourPlot[0.000157223 10^(2 x - 2 y) == 100, {x, -6, -1}, {y, -6, -1}] does plot the contour. – Rahul Mar 24 at 16:32
up vote 6 down vote accepted

Ah, what's happening is that the contour you want is outside the automatically chosen PlotRange. Observe:

ContourPlot[0.000157223 10^(2 x - 2 y), {x, -6, -1}, {y, -6, -1}]

enter image description here

The contour you want would be in the white part, whose values are extremely high compared to the automatically drawn contours. Instead you have to force the PlotRange to contain the contour, for example by setting it to All:

ContourPlot[0.000157223 10^(2 x - 2 y), {x, -6, -1}, {y, -6, -1}, Contours -> {100},
 ContourShading -> None, PlotRange -> {Full, Full, All}]

enter image description here

share|improve this answer
    
Thanks for posting as answer! (+1) – MarcoB Mar 24 at 16:53

Working blind.. here is a little trick to let you visualize where ContourPlot evaluates your function and help you find appropriate settings for PlotPoints and MaxRecursion. I think MaxRecursion doesn't help if it doesn't even spot the countour on first pass.

cv = 3/4;
Show[
 MapAt[Graphics[{If[#[[3]] > cv, Red, Blue], 
       Point[#[[1 ;; 2]]]} & /@ #[[1]]] &,
  Reap[ContourPlot[  (fv = Sin[x] Cos[y]) == cv , 
      {x, -4, 4}, {y, -4, 4},
    EvaluationMonitor :> Sow[{x, y, fv}],
    MaxRecursion -> 2, PlotPoints -> 5]], {2}]]

enter image description here

Applying this to your example,

cv = 100;
Show[
 MapAt[Graphics[{If[#[[3]] > cv, Red, Blue], 
       Point[#[[1 ;; 2]]]} & /@ #[[1]]] &,
  Reap[ContourPlot[
    fv = 0.000157223 10^(2 x - 2 y), {x, -6, -1}, {y, -6, -1}, 
    Contours -> {1, 10, 100, 1000}, 
    EvaluationMonitor :> Sow[{x, y, fv}], 
    ContourShading -> None]], {2}]]

enter image description here

you see it is finding the contours just fine so it seems like a glitch in contourshading. (I tried playing with ContourStyle with no success )

As noted by @Rahul in comments this works:

ContourPlot[ 0.000157223 10^(2 x - 2 y) == {1, 10, 100,  1000},
  {x, -6, -1}, {y, -6, -1}]

enter image description here

share|improve this answer

With shading and legend.

ContourPlot[0.00015 10^(2 x - 2 y), {x, -6, -1}, {y, -6, -1}, 
 Contours -> {1, 10, 100, 1000, 10000, 100000},
 ColorFunctionScaling -> False,
 ColorFunction -> (ColorData["StarryNightColors"][Rescale[Log10[#], {0, 6}]] &),
 PlotRange -> Full,
 PlotLegends -> Automatic]

![enter image description here

share|improve this answer

Your Answer

 
discard

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.