0
$\begingroup$

When I try to create a ContourPlot of a continuous conditional function, Mathematica leaves a "seam" in between the two regions demarcated by the conditional. How do I fill this seam?

fn[x_, y_] := If[x < 2, y/x^2, y/(2 x)]
ContourPlot[fn[x, y], {x, 1.5, 2.5}, {y, 0, 2}]

enter image description here

$\endgroup$
3
  • $\begingroup$ The PlotPoints -> 500 option helps. $\endgroup$
    – user64494
    Sep 16, 2020 at 7:48
  • 4
    $\begingroup$ add the option Exclusions -> None? $\endgroup$
    – kglr
    Sep 16, 2020 at 7:50
  • $\begingroup$ @kglr, that seems to solve the problem. Feel free to write up an answer to my trivial question and I'll mark it answered. $\endgroup$
    – Corvus
    Sep 16, 2020 at 7:59

1 Answer 1

4
$\begingroup$

Adding the option Exclusions -> None fixes the issue:

 ContourPlot[fn[x, y], {x, 1.5, 2.5}, {y, 0, 2}, Exclusions -> None]

enter image description here

$\endgroup$
1
  • $\begingroup$ Thank you so very much! $\endgroup$
    – Corvus
    Sep 16, 2020 at 9:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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