Vertical Lines at steps of HeavsideTheta

I want to plot the following:

Plot[{Sqrt[x], Sum[HeavisideTheta[x - n^2], {n, 1, Floor[x]}]}, {x, 0,50}]


which looks like

Is there a simple way to get this same plot with vertical lines at the jumps between steps?

• I'm not sure what happened but I was messing around and suddenly the steps appeared, I'm not sure why, the code is exactly the same, but now it is throwing this error: Plot::exclul: {Sin[\[Pi] Re[x]]-0,Sin[\[Pi] Im[x]]-0,Im[-n^2+x]-0,(-n^2+x)-0} must be a list of equalities or real-valued functions. – Kai Dec 3 '17 at 3:10

See the option Exclusions:

Plot[{Sqrt[x], Sum[HeavisideTheta[x - n^2], {n, 1, Floor[x]}]}, {x, 0, 50},
Exclusions -> None]


The only easy method I'm aware of is to make it a parametric plot instead.

wrapper[f_] := {#1, f[#1]} &;
ParametricPlot[
{wrapper[Sqrt][x],
wrapper[Sum[HeavisideTheta[# - n^2], {n, 1, Floor[#]}] &][x]}
, {x, 0, 50}
]


Produces the output:

I also receive this error you mention in your comment. I don't understand why; maybe ParametricPlot thinks the functions may not have real values. If you're confident there's no problem with your input, you can wrap ParametricPlot in Quiet[ ... , ParametricPlot:exclul to prevent this message from appearing.