# HIghlight integer coordinates in continuous plot

Suppose I have the plot of some function y = f(x):

Plot[f(x),{x, x_min, x_max}]


Is there any option to highlight all coordinates (x,y) when both of them are integer?

• Please be more specific about what you mean by "integer coordinates". Integer x? Integer f(x)? Or both have to be integer? – Szabolcs Feb 15 at 21:01

f[x_] := 5 x^2/3

{xmin, xmax} = {0, 10};

pts = Select[
Table[{x, f[x]}, {x, Ceiling[xmin], Floor[xmax]}],
IntegerQ[#[]] &]

(* {{0, 0}, {3, 15}, {6, 60}, {9, 135}} *)

Plot[f[x], {x, xmin, xmax}, Epilog -> {Red,
AbsolutePointSize, Point[pts]}] ClearAll[f]
f[x_] := .5 x + (x - 1)^2


### DiscretePlot + ConditionalExpression + FractionalPart

Show[Plot[f[x], {x, 0, 6}, ImageSize -> Large,
Ticks -> {Range, Range[0, 30]},
GridLines -> {Range, Full}],
DiscretePlot[ConditionalExpression[f[x], FractionalPart[f[x]] == 0.], {x, 0, 6},
PlotStyle -> Red, Filling -> False]] ### MeshFunctions + FractionalPart

Plot[f[x], {x, 0, 6},
MeshFunctions -> {FractionalPart[f@#] &},
Mesh -> {{0.}},
MeshStyle -> Directive[Red, PointSize[Large]],
Ticks -> {Range, Range[0, 30]},
GridLines -> {Range, Full},
PlotPoints -> {100, Range[0, 6]},
Method -> {"BoundaryOffset" -> False},
ImageSize -> Large] We get the same picture using the option settings:

MeshFunctions -> {# &} (* and *)
Mesh -> {Select[FractionalPart[f@#] == 0. &]@Range[0, 6]}


or

MeshFunctions -> {Boole[FractionalPart[#2] == 0.] Boole[
FractionalPart[#] == 0.] &}  (* and *)
Mesh -> {{1}}


Note: In the second approach, the option setting PlotPoints -> {100, Range[0, 6]} ensures that sampling includes points with integer horizontal coordinates and the setting Method -> {"BoundaryOffset" -> False} ensures that the end-points are included in mesh calculation.