3
$\begingroup$

I want to achieve this effect: enter image description here

then, I try the following code:

p = ContourPlot[(x - 2)^2 + y^2 == 1, {x, 1, 3}, {y, -1, 1}, 
Axes -> True, Frame -> False, AxesOrigin -> {0, 0}, 
PlotRange -> All, AspectRatio -> Automatic, 
Exclusions -> {x <= 2 || y <= 0}, ExclusionsStyle -> Dashed]

however, it didn't work. How to do?

$\endgroup$
1
  • 1
    $\begingroup$ That means you don't want to exclude the dashed line? Try RegionFunctioninstead of Exclusions! $\endgroup$ Feb 7, 2019 at 10:15

1 Answer 1

5
$\begingroup$

Try RegionFunction instead of Exclusions:

p1 = ContourPlot[(x - 2)^2 + y^2 == 1, {x, 1, 3}, {y, -1, 1}, RegionFunction ->  (#2 <= 0 || #1 <= 2 &) , ContourStyle -> Dashed];
p2 = ContourPlot[(x - 2)^2 + y^2 == 1, {x, 1, 3}, {y, -1, 1},RegionFunction ->   (#2 > 0 && 2 <= #1 <= 3 &) ,ContourStyle -> Blue];
Show[{p1, p2}, Axes -> True, Frame -> False, AxesOrigin -> {0, 0},PlotRange -> All, AspectRatio -> Automatic]

enter image description here

$\endgroup$

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.