The function in that range, jumps from minus infinity to plus infinity. These jumps occur, in the case of rational functions, in correspondence of the poles of the function. This is what happens to your function. We should analytically determine the values of x that make the function infinite. In other words a method could be this: what are the value of x which make the first derivative of f(x) equal to π / 2.
1) The definition of h.plot is wrong in the first line. The wrong version cannot be distinguished from the correct one with the naked eye. In the left placeholder of the "on error" statement there is only "NaN". Then the whole "on error" statement must be assigned to F. You made the assigment "F <- NaN" in the left placehoder of the "on error" statement.
I tried to make it more clear by highlighting it in yellow and setting parenthesis in the picture below
2) The second problem is the range variable used for plotting. You defined a range from -3 to 2 with a step width of 1. Thats far to coarse. My stepwidth 0.001 may be a bit too fine and you may try -3,-2.99 .. 2.
BTW, you don't have to use a range variable for plotting at all. Delete the definition of x.plot and see how mathcad choses its own range for plotting. This feature is called "quick plot". Most the time it works fine but I nevertheless often find it better to use a range as it gives me the control over start and stop value and stepwidth.
I try to avoid to name that variable which is just used for plotting "x" as I usually want x to be a "free" variable without any value. Thats the reason for naming it "x.plot". Often I name it just "x." because when the focus is outside of the plot this variable looks like "x".
BTW, your function h(x) plot quite fine without any vertical artefact if you use a simple quickplot. No need for any tricks 😉