Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>For what it's worth, I like the simple solution as well. Plus it is easy to use the same coloring function for both the surface and the points:</p> <pre><code>g = Plot3D[Sin[x + y^2], {x, -3, 3}, {y, -2, 2}, Mesh -&gt; {1, 4}, Boxed -&gt; False, ColorFunction -&gt; "Rainbow"]; p = ListPointPlot3D[Table[{x, y, Sin[x + y^2]}, {x, -3, 3, (3 - (-3))/(1 + 1)}, {y, -2, 2, (2 - (-2))/(4 + 1)}], ColorFunction -&gt; "Rainbow", PlotStyle -&gt; PointSize[Large]]; Show[g, p] </code></pre> <p><img src="https://i.stack.imgur.com/qZQpD.png" alt="enter image description here"></p> <p><strong>Edit:</strong> If we want to make this into a customized myPlot3D, I think the following should do:</p> <pre><code>myPlot3D[f_, {x_, xmin_, xmax_}, {y_, ymin_, ymax_}, Mesh -&gt; {i_Integer, j_Integer}, opts : OptionsPattern[]] := Module[{g = Plot3D[f, {x, xmin, xmax}, {y, ymin, ymax}, Mesh -&gt; {i, j}, Evaluate@FilterRules[{opts}, Options[Plot3D]]], stx = (xmax - xmin)/(i + 1), sty = (ymax - ymin)/(j + 1), pts}, pts = ListPointPlot3D[ Table[{x, y, f}, {x, xmin + stx, xmax - stx, stx}, {y, ymin + sty, ymax - sty, sty}], Evaluate@FilterRules[{opts}, Options[ListPointPlot3D]]]; Show[g, pts]]; </code></pre> <p>Note that options are applied to both plots, but are filtered first. I also removed the points on the contour of the plot. For example, </p> <pre><code>myPlot3D[Sin[x + y^2], {x, -3, 3}, {y, -2, 2}, Mesh -&gt; {4, 10}, Boxed -&gt; False, ColorFunction -&gt; "Rainbow", Axes -&gt; False, PlotStyle -&gt; PointSize[Large]] </code></pre> <p>will give as a result</p> <p><img src="https://i.stack.imgur.com/MRw8Z.png" alt="enter image description here"></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload