2
$\begingroup$

How do I plot a 2d curve and label lattice points to one side of it?

I want to plot the curve $f[x]=\frac{1}{x}$, and draw a solid red dot at every lattice point in the following set: $$\{(m,n)\in \mathbb N^2\colon mn\geq 1\}$$

$\endgroup$
  • $\begingroup$ Make a lattice with Tuples, filter it with Select, plot with ListPlot, combine it with the curve using Show. $\endgroup$ – Szabolcs Jul 23 '15 at 6:37
  • $\begingroup$ You can add something like Epilog -> {Red, Point[Flatten[Array[List, {5, 5}], 1]]} to your plot. $\endgroup$ – J. M.'s discontentment Jul 23 '15 at 6:41
5
$\begingroup$

In V10.1 or later, you can use CoordinateBoundingBoxArray to generate the lattice.

With[{m = 5},
  Plot[1/x, {x, 0, m},
    Epilog -> {
      Red, PointSize[Medium],
      Point[Flatten[CoordinateBoundingBoxArray[{{1, 1}, {m, m}}], 1]]},
    AspectRatio -> Automatic,
    PlotRange -> {0, m},
    PlotRangePadding -> .15,
    Frame -> True]]

plot

| improve this answer | |
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.