3
$\begingroup$

I have a continous function f(x,y), and I want the 2D plot of its sign. I then created a function

sign=Sign[f]

and used ContourPlot: what I obtained is this graph

enter image description here

where the blue region corresponds to -1 and the yellow region to 1. Can I get rid of the white region? It does not depend on the function, as there are points in it with -1 or 1 sign.

Thank you in advance!

EDIT: the exact expression of f, in its original variables h and mu, is

1/mu^4*( 0.0562706 (-0.308221 + Sqrt[0.1 + h + mu]) (-2.01155 + 
   1. Sqrt[0.1 + h + mu]) (-0.324443 - 3.24443 h - 11.7611 mu + 
   1. Sqrt[0.1 + h + mu]) (-0.049713 - 0.49713 h - 1.8021 mu + 
   1. Sqrt[0.1 + h + mu]) (-0.0431301 - 0.431301 h + 1. mu - 
   0.737425 Sqrt[0.1 + h + 1.09109 mu]) (-0.0431301 - 0.431301 h + 
   1. mu + 0.133495 Sqrt[0.1 + h + 1.09109 mu]) (-0.309516 + Sqrt[
   0.1 + h + 1.09109 mu]) (1.70977 + 1. Sqrt[0.1 + h + 1.09109 mu]))
$\endgroup$
6
  • 1
    $\begingroup$ Welcome to Mathematica.SE, Ire! I suggest the following: 1) Take the tour and check the faqs. 2) When you see good questions and answers, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge. Also, please remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign! 3) As you receive help, try to give it too, by answering questions in your area of expertise. $\endgroup$
    – Chris K
    Mar 4 at 16:09
  • $\begingroup$ Could you add the definition of your function f? $\endgroup$
    – Chris K
    Mar 4 at 16:09
  • $\begingroup$ Hi, thank you for your interest! The exact expression of f is very long, but I'm about to copypaste it in the question. $\endgroup$
    – Ire
    Mar 4 at 16:40
  • $\begingroup$ I think you'll find RegionPlot more useful here since ContourPlot works best with continuous functions. $\endgroup$ Mar 4 at 17:25
  • $\begingroup$ @bills Yes, actually in my plot mu starts from 0.1. $\endgroup$
    – Ire
    Mar 4 at 17:43
3
$\begingroup$

Add the options PlotRange -> All and Exclusions -> None:

ContourPlot[Sign[f[h, mu]], {h, 0, 100}, {mu, 0, 20}, 
 Contours -> {{0}}, ContourStyle -> Red, PlotPoints -> 100, 
 PlotRange -> All, Exclusions -> None]

enter image description here

$\endgroup$
1
$\begingroup$

With your data, I get a complete different plot. For clarity., I only plot the zero contour:

f[h_, mu_] := 
  1/mu^4*(0.0562706 (-0.308221 + Sqrt[0.1 + h + mu]) (-2.01155 + 
        1. Sqrt[0.1 + h + mu]) (-0.324443 - 3.24443 h - 11.7611 mu + 
        1. Sqrt[0.1 + h + mu]) (-0.049713 - 0.49713 h - 1.8021 mu + 
        1. Sqrt[0.1 + h + mu]) (-0.0431301 - 0.431301 h + 1. mu - 
        0.737425 Sqrt[0.1 + h + 1.09109 mu]) (-0.0431301 - 
        0.431301 h + 1. mu + 
        0.133495 Sqrt[0.1 + h + 1.09109 mu]) (-0.309516 + 
        Sqrt[0.1 + h + 1.09109 mu]) (1.70977 + 
        1. Sqrt[0.1 + h + 1.09109 mu])) // Simplify;

ContourPlot[f[h, mu] == 0, {h, 0, 100}, {mu, 0, 20}, 
 FrameLabel -> {"h", "mu"}, ContourLabels -> Automatic]

enter image description here

$\endgroup$
1
  • $\begingroup$ You're totally right, I modified the image which now matches with yours. $\endgroup$
    – Ire
    Mar 4 at 17:42
1
$\begingroup$

Or RegionPlot

RegionPlot[{f[h, mu] < 0, f[h, mu] > 0}, {h, 0, 100}, {mu, 0, 20}, 
 FrameLabel -> {"h", "mu"}, PlotPoints -> 200, 
 PlotStyle -> {Red, Green}, BoundaryStyle -> Yellow]

enter image description here

$\endgroup$
1
  • $\begingroup$ Yes, also RegionPlot works great! $\endgroup$
    – Ire
    Mar 5 at 14:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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