While plotting a slow to evaluate function and trying to get some sense of progress, I noticed that Mathematica traverses the grid of points twice. Here's the reduced example:
points = {};
Dynamic[
Show[
ListPlot[Take[points, Max[0, Length@points - 5]], PlotRange -> All],
ListPlot[
Take[points, -Min[Length@points, 5]], PlotRange -> All,
PlotStyle -> Directive[PointSize[Large], Opacity[0.1], Red]
],
AspectRatio -> Automatic
]
]
Monitor[
Plot3D[Pause[0.05]; 0, {a, -5, 5}, {b, -5, 5},
PlotRange -> All, PlotPoints -> 10, MaxRecursion -> 0],
AppendTo[points, {a, b}];
]
If you watch the plot, you'll see that the red points move twice over the grid. If you inspect the plots
variable after plotting, you'll see that not all the points are duplicates: some are offset from their originals by $\sim10^{-8}$.
Why does Plot3D
do this, even though I asked for MaxRecursion -> 0
? Is there any way to convince it to only scan the function once (not having to resort to ListPlot3D
+ Table
)?
Answer
I guess the second pass is for computing the vertex normals. At least the behavior of Plot3D
is quite different (and somewhat erratic) when we set the option NormalsFunction -> None
.
Comments
Post a Comment