# How to plot a graph similar to this figure in Mathematica?

I am trying to plot a graph similar to

I have tried using ContourPlot with GridLines as

ContourPlot[x^2 + y^2 == 400, {x, -40, 40}, {y, -40, 40},
LabelStyle -> Directive[Black, FontSize -> 18],
GridLines -> Automatic]


However this only plots a circle with a transparent interior. But I want the inside to be dark just like in the figure. Also GridLines only shows the dark lines around -40,-20,0,20,24 without the grey lines inbetween. Is there a better way to do it?

• ContourPlot should only plot a circle, which is the solution of your equation. Try RegionPlot[x^2 + y^2 < 400, {x, -40, 40}, {y, -40, 40}] instead. Another approach would be using Disk[] and Line. Commented Oct 21, 2016 at 18:17
• @anderstood, But how to use Disk[] with gridlines?
– MrDi
Commented Oct 21, 2016 at 18:25
• @MrDi You could something like this: Graphics[{Gray, Disk[{0, 0}, 20]}, Frame -> {{Automatic, None}, {Automatic, None}}, PlotRange -> {{-50, 50}, {-50, 50}}, GridLines -> {Range[-50, 50, 2], Range[-50, 50, 2]}].
– user31159
Commented Oct 21, 2016 at 18:27
• @xavier, thank you this is really helpful but can the lines around -40,-20,0,20,40 be dark than the others.
– MrDi
Commented Oct 21, 2016 at 18:29
• I am going to post an answer with this additional update.
– user31159
Commented Oct 21, 2016 at 18:42

You can alternatively use Graphics with the primitive Disk.

Definitions.

disk = {Darker[Gray, 0.5], Disk[{0, 0}, 20]};
frame = {{Automatic, None}, {Automatic, None}};
plotrange = {{-50, 50}, {-50, 50}};

gridlines = ConstantArray[
Join[
(* all lines *)
{#, Directive[LightGray, Thin]} & /@ Range[-50, 50, 2],
(* main lines *)
{#, Directive[Lighter[Black, 0.5]]} & /@ Range[-40, 40, 20]],
2
];

labelstyle = Directive[Black, FontSize -> 18];


Graphics.

Graphics[disk,
Frame -> frame, PlotRange -> plotrange, GridLines -> gridlines,
LabelStyle -> labelstyle
]


The symbol gridlines could be instead defined with a DownValues, as shown by anderstood in his answer. This would read here:

Clear[gridlines];
gridlines[min_, max_] := Table[
If[Divisible[i, 20],
(* main lines *)
{i, Directive[Lighter[Black, 0.5]]},
(* other lines *)
{i, Directive[LightGray, Thin]}
],
{i, Ceiling[min], Floor[max], 2}
];


Update

To get outward ticks, as in the graphics of the question, you can define:

myticks[min_, max_] := Table[
If[Divisible[i, 20],
(* ticks for main lines *)
{i, i, {0, 0.005}},
(* ticks for other lines *)
{i, "", {0, 0.005}}
],
{i, Ceiling[min], Floor[max], 2}
];

frameticks = {{myticks[##] &, None}, {myticks[##] &, None}};


which gives

Graphics[disk,
Frame -> frame, FrameTicks -> frameticks,
PlotRange -> plotrange, GridLines -> gridlines,
LabelStyle -> labelstyle
]


• What about ticks? yours are inward... should be outward? Commented Oct 21, 2016 at 19:08
• @BlacKow Good point! I will make an update to this answer later today.
– user31159
Commented Oct 21, 2016 at 19:16
– user31159
Commented Oct 21, 2016 at 19:41

grids[min_, max_] :=
Table[If[Mod[i, 20] == 0, {i, Black}, {i, Gray}], {i, Ceiling[min],
Floor[max], 1}]
RegionPlot[x^2 + y^2 < 400, {x, -40, 40}, {y, -40, 40}, GridLines -> grids]


Slight variation: increase grid spacing, change blue to gray, increase ticks label size and reduce disk diameter with:

grids[min_, max_] :=
Table[If[Mod[i, 20] == 0, {i, Black}, {i, Gray}], {i, -40, 40, 2}]
RegionPlot[x^2 + y^2 < 300, {x, -40, 40}, {y, -40, 40},
GridLines -> grids, PlotStyle -> Directive[Lighter[Black, 0.4]],
BoundaryStyle -> Gray, LabelStyle -> Directive[Black, FontSize -> 18]]