This is probably not a complete answer. Plot
attempts at some point to detect discontinuities symbolically. With a few built-ins, it can do it. Round[x]
is an example but for some reason Round[x, 1]
is not
Those discontinuities are excluded from the plots (see Exclusions
)
So, for example, compare the output of these
Plot[Round[x], {x, -3, 3}]
Plot[Round[x, 1], {x, -3, 3}]
If you define r[x_?NumericQ]:=Round[x]
, then r[x]
behaves the same way as Round[x, 1]
because it doesn't know how to manipulate your custom r
symbolically
Now, if Plot
already knows beforehand it has a discontinuity somewhere, it can be smarter than usual. For example, it can try to make the discontinuities sharper by sampling right on the sides.
x1 = Reap[
Plot[Round[x, 1], {x, -3, 3}, Filling -> Axis,
EvaluationMonitor -> Sow[x]]][[-1, 1]] // Rest;
x2 = Reap[
Plot[Round[x], {x, -3, 3}, Filling -> Axis,
EvaluationMonitor -> Sow[x]]][[-1, 1]] // Rest;
Complement[x2, x1]
{-2.50191, -2.49809, -1.50191, -1.49809, -0.501913, -0.498087, \
0.498087, 0.501913, 1.49809, 1.50191, 2.49809, 2.50191}
As to the rendering issues with the Filling
, that's because it excludes discontinuities by default. Try with Exclusions->None
Plot[Round[x], {x, -3, 3}, Filling -> Axis, Exclusions -> None]
Related question: Managing Exclusions in Plot[ ]
Round[x,1]
. This uses 163 points, the same asRound[x,10]
whereas without, it uses 175 points. You'll find some general info on how the points are chosen in this answer $\endgroup$