# Graphics Disk[] with a hole

I have a simple question I have no answer to - how do I create an Epilog in (for example) a DensityPlot that consists of a Disk[] with a hole with the inner radius being r1 and the outer radius being r2? Imagine something like this:

Graphics[{{Gray, Disk[{0, 0}, 1]}, {White, Disk[{0, 0}, 0.5]}}]


However, this would hide the density plot in the "hole" (it would stay white). How to create such object as an epilog to a density plot, stream plot etc?

I had two ideas: first, if there is something like GraphicsDifference, that would be it: bigger Disk minus the smaller one creates the object I'm after. However, I found no such function.

Second: create a circle using a really thick line so that the inner boundary corresponds to r1 and the outer to r2. However this would not scale nicely (i.e. using ImageSize -> ... during export would not preserve these radii).

Thanks.

• Annulus was introduced in 10.2 – Kuba May 9 '18 at 20:32
• Thanks, that's great! Exactly what I was looking for! I googled a lot of queries like "Disk with a hole", but nothing returned Annulus...I am sorry though. Just curious: how would you make a graphics with rectangular hole so that the hole is transparent (the plot is visible through it)? So as to keep to the spirit of the original question... – user16320 May 9 '18 at 20:36
• A disk with a rectangular hole or a rectangle? – Kuba May 9 '18 at 20:46

## 3 Answers

use region tools to construct more general figures (addressing comment):

r = RegionDifference[ Disk[{8, 8}, 2], Rectangle[{7, 7}, {9, 8}]];
Show[
ContourPlot[Cos[x] + Cos[y], {x, 0, 4 Pi}, {y, 0, 4 Pi}],
RegionPlot[r, Frame -> False, PlotStyle -> Red,
BoundaryStyle -> Black]]


or

ContourPlot[Cos[x] + Cos[y], {x, 0, 4 Pi}, {y, 0, 4 Pi},
Epilog ->
First@RegionPlot[r, Frame -> False, PlotStyle -> Red,
BoundaryStyle -> Black]] • This is what I've been looking for! Thank you. – user16320 May 9 '18 at 22:20

Nowadays, Polygon[] supports holes. Using george's example:

hole = Polygon[MeshPrimitives[BoundaryDiscretizeGraphics[Disk[{8, 8}, 2]],
2][[1, 1]] -> {{7, 7}, {9, 7}, {9, 8}, {7, 8}}];

ContourPlot[Cos[x] + Cos[y], {x, 0, 4 π}, {y, 0, 4 π},
Epilog -> {Directive[Red, EdgeForm[Directive[Thick, Black]]], hole}] Use BezierCurve and FilledCurve. Just for fun.

c = 4/3 Tan[π/8];
pts = {{0, 1}, {c, 1}, {1, c}, {1,
0}, {1, -c}, {c, -1}, {0, -1}, {-c, -1}, {-1, -c}, {-1, 0}, {-1,
c}, {-c, 1}, {0, 1}};
Graphics[{Orange,
FilledCurve[{{BezierCurve[3 pts]}, {BezierCurve[
2 pts]}, {BezierCurve[pts]}}]}] 