Is this a bug in plotting step functions?

The following simple code generates a flawed plot:

f[t_] := UnitStep[t - 14.1] + UnitStep[t - 14.5] + UnitStep[t - 14.9]

Plot[f[t], {t, 0, 16}, Filling -> Axis, Exclusions -> None]


I never expected part of the connection is slanted. Although I can fix this issue in many ways (such as using PlotPoints option, changing the plot ranges), this behavior is still surprising to me. Could anyone explain this? (I'm using Mathematica 11.3)

• Please try to avoid using the bugs tag unless it has been confirmed as a bug by Wolfram or the community agrees that this is a bug. Commented Jun 7, 2019 at 16:08

f[t_] := UnitStep[t - 14.1] + UnitStep[t - 14.5] + UnitStep[t - 14.9]


Adding Exclusions will cause Plot to look closely in the region of the Exclusions and result in clean steps.

Plot[f[t], {t, 0, 16},
Exclusions -> {14.1, 14.5, 14.9},
Filling -> Axis]


EDIT: You will get the same result with Exclusions -> True. END EDIT

Or use the option MaxRecursion

Plot[f[t], {t, 0, 16},
MaxRecursion -> 10,
Filling -> Axis]


Update: We can use a special form {numberofpoints, {list of points}} for the option setting for PlotPoints as an alternative to setting a very large value (see see this answer by Ullrich Neumann):

Plot[f[t], {t, 0, 16}, Filling -> Axis,
PlotPoints -> {50, {14.1, 14.5, 14.9}},
Exclusions -> None]


Add the option PlotPoints with a large value:

Plot[f[t], {t, 0, 16}, Filling -> Axis, Exclusions -> None,
PlotPoints -> 200]


Alternatively,

Quiet @ Plot[f[t], {t, 0, 16}, Filling -> Axis, Exclusions -> None,
Method -> {"MaxBend" -> 0}]


same picture