# How to create grid lines as dots?

I need to denote only dots at grid crossings. How to make this in Mathematice? GridLinesStyle does not contain appropriate option.

• How about GridLinesStyle -> Directive[Dotted, Blue] ? Commented Apr 1, 2020 at 16:20

This could be a starting point:

xvals = Range[10];
yvals = Range[-1, 1, 0.2];

Plot[Sin[x], {x, 0, 10},
Prolog -> {AbsolutePointSize[1], Point@Tuples[{xvals, yvals}]}
]


• So, you just drew them... Thanks!
– Dims
Commented Apr 1, 2020 at 18:16
• @Dims I do not think that there is any other way. GridLines are always lines (possibly with a dashed/dotted style), and you asked for points instead of lines. Commented Apr 3, 2020 at 10:17

Post-processing to replace grid lines with dots aligned with automatically generated ticks:

ClearAll[gL, grdLns, dottedGridlines]
gL[plt_, xy_, spec_: Automatic] := Replace[DeleteDuplicatesBy[
ChartingFindTicks[{0, 1}, {0, 1}][## & @@ PlotRange[plt][[xy]]][[All, ;; 2]], First],
{{a_, ""} :> (spec /. {Automatic -> Nothing, Full -> a}), {a_, _} :> a}, 1]

grdLns[plt_][a : {__List}] := Tuples @ a
grdLns[plt_][{a_List, s : (Automatic | Full)}] := Tuples @ {a, gL[plt, 2, s]}
grdLns[plt_][{s : (Automatic | Full), a_List}] :=  Tuples @ {gL[plt, 1, s], a}
grdLns[plt_][s : {(Automatic | Full) ..}] := Tuples @ {gL[plt, 1, s[[1]]],
gL[plt, 2, s[[2]]]}
grdLns[plt_][s : (Automatic | Full)] := grdLns[plt][{s, s}]
grdLns[plt_][] := grdLns[plt][Options[plt, GridLines][[1, 2]] /. _Function -> Full]

dottedGridlines = Show[#, Epilog -> Point[grdLns[#][]], GridLines -> None] &;


Examples:

{plt1, plt2, plt3} = Plot[Sin[x], {x, 0, 10}, GridLines -> #, Frame -> True,
Axes -> False, ImageSize -> 340, PlotLabel -> "GridLines -> " <> ToString@#] & /@
{Automatic, Full, {Range[2, 6], Automatic}};

Row[{plt1, plt2, plt3}, Spacer[10]]


Row[dottedGridlines /@ {plt1, plt2, plt3}, Spacer[10]]


Note: The option setting Full for GridLines is not documented.

Graphics[Circle[], Axes -> True, GridLines -> Automatic,
GridLinesStyle -> Directive[Orange, Dotted]]


Plot[Cos[x], {x, 0, 10}, Ticks -> {None, Automatic},
GridLines -> {{Pi, 2 Pi, 3 Pi}, {-1, -.5, .5, 1}},
GridLinesStyle -> Directive[Gray, Dotted]]


This expands a bit on @Szbolcs answer. I suppose one could calculate the positions of the horizontal and vertical dots automatically. A bit tedious, that would be. It would be nicer if there were a GridLinesStyle Dotted option, but it does not seem to exist.

(*horizontal dots*)
ls1 = ListPlot[Table[{i/10, 0.05 j}, {i, 0, 100}, {j, 0, 10}], PlotStyle -> Black];

(*vertical dots*)
ls2 = ListPlot[Table[{i, 0.01 j}, {i, 0, 10}, {j, 0, 50}], PlotStyle -> Black];

(*whatever curve*)
pl1 = Plot[Sin[y]/4 + 1/4, {y, 0, 10}];

Show[ls1, ls2, pl1]
`