I would use Piecewise
:
f[x_] := Piecewise[{{40 - 6 x, 0 <= x < 3}, {12 - 6 x,
3 <= x < 8}, {60 - 6 x, 8 <= x <= 10}}];
Plot[f[x], {x, 0, 10}, Filling -> Axis]
Plot[f[x], {x, 0, 10}, Exclusions -> Automatic,
ExclusionsStyle -> Directive[Red, Dashed]]
Show[%, %%]
Curiously, I could not combine Exclusions
with Filling
in a single Plot
command.