# Plot Two Circles and Color Their Difference

I am trying to plot two circles with a radius of $$1$$ and another with a radius of $$9$$. Both are centered at $$(0,-1)$$. I then want to color in the distance between the circle of radius 9 and the circle of radius 1.

Plot[Graphics[{Blue, Circle[{0, -1}, 9]}] Graphics[{Blue, Dashed,
Circle[{0, -1}, 1]}], {x, -10, 10}, {y, -10, 10}]


I have the above, but it is wrong. I would like a graph of both with axes.

I am trying to plot the region in the complex plane from $$1< \mid(z+i)\mid \le3$$, which I determined to be the two circles from above.

• What do you mean by "want to color in the distance"? Commented Sep 17, 2015 at 14:57
• So color the region from circle with radius 1 to circle with radius 9. Essentially forming a disc Commented Sep 17, 2015 at 14:59
• Graphics[{Green, Disk[{0, -1}, 9], White, Disk[{0, -1}, 1]}, Axes -> True] Commented Sep 17, 2015 at 15:01
• Following the code in the question the answer-comment above can be modified as: Graphics[{Green, EdgeForm[{Thick, Blue}], Disk[{0, -1}, 9], EdgeForm[{Thick, Blue, Dashed}], White, Disk[{0, -1}, 1]}, Frame -> True] Commented Sep 17, 2015 at 15:07

With borders:

Graphics[{LightBlue, Disk[{0, -1}, 9], Blue, Circle[{0, -1}, 9],
Dashed, Thick, Circle[{0, -1}, 1], White, Disk[{0, -1}, 1]},
Axes -> True]


Using Region objects is overkill if your problem only entails drawing out these circles, but if you want to do further calculations with them, the approach might still interest you. Besides, it quite directly translates your question about the difference of two geometric regions into the MMA language.

DiscretizeRegion[
RegionDifference[Disk[{0, -1}, 9], Disk[{0, -1}, 1]],
MaxCellMeasure -> 0.01, PlotTheme -> "Polygons", Axes -> True
]


The RegionDifference region is now a fully computable geometric region, i.e. for instance you could use it as an integration domain, to solve differential equations, etc. See for instance: Derived Regions.

• I like this a lot more. It helps if I were to do so much more with this problem. Thank you. Commented Sep 17, 2015 at 15:45

Just for Fun.

The equation for a Circle with center at the origin would be

circle = r^2 == x^2 + y^2


And we can use this knowledge to plot a circle with Radius r

r = 1;
RegionPlot[r^2 > x^2 + y^2, {x, -2, 2}, {y, -2, 2}]


The equation for a Circle from the origin shifted would be

circleShifted = r^2 == (x - a)^2 + (y - b)^2


and with the Parameters given

r1 = 1; r2 = 9;
{a, b} = {0, -1};


we can plot the desired Function

RegionPlot[{r1^2 < (-a + x)^2 + (-b + y)^2 < r2^2},
{x, -12, 12}, {y, -12, 12}, Axes -> True, BoundaryStyle -> Red,
PlotStyle -> {Blue}]


If circles are concentric, then the resulting shape is called an Annulus.

Graphics[{
EdgeForm[{Thin, Dashed, Black}]
, FaceForm[Lighter@Cyan]
, Annulus[{-1, 0}, {1, 9}]
, AbsolutePointSize[4], Black
, Point@{-1, 0}
}
, Frame -> True
]


The RegionDifference solution provided by @MarcoB would be my go-to choice, however.

• Another version of @ubpdqn, using WindingPolygon with "EvenOddRule"
Manipulate[
Graphics[{Brown,
WindingPolygon[{CirclePoints[c1, 2, 50], CirclePoints[c2, 1, 50]},
"EvenOddRule"]}, PlotRange -> 5], {{c1, {0, 0}}, Locator,
Appearance -> Automatic}, {{c2, {1, 1}}, Locator,
Appearance ->
Graphics[{Blue, AbsolutePointSize[8], Point[{0, 0}]}]}]

• Or FilledCurve.
Manipulate[
Graphics[{Brown,
FilledCurve[{{Line@CirclePoints[c1, 2, 50]}, {Line@
CirclePoints[c2, 1, 50]}}]}, PlotRange -> 5], {{c1, {0, 0}},
Locator, Appearance -> Automatic}, {{c2, {1, 1}}, Locator,
Appearance ->
Graphics[{Blue, AbsolutePointSize[8], Point[{0, 0}]}]}]


For more general circle overlaps (a bit clunky):

Manipulate[
Module[{d1 = Disk[a, b], d2 = Disk[c, d]},
DiscretizeRegion[RegionSymmetricDifference[d1, d2],
PerformanceGoal -> "Quality",
PlotRange -> Table[{-3, 3}, 2]]], {{a, {0, 0}}, Locator}, {b, 0.1,
2}, {{c, {0.2, 0.2}}, Locator}, {d, 0.2, 1}]