Fix plot piecewise function

flat function in `plot.py` does not convert the vector to float type, thus numpy return AttributeError: sqrt.

Convert the vector explicitly to np.float will fix this bug.