First of all, DON'T use sum as the name of your variable because you'll no longer have access to the built-in function by that name. Call it "theSum" or something else.
Secondly, all you're doing is adding up a bunch of numbers to get a single number out, then you plot it (or try to). What do you expect to see? sum is not an array and does not have different values for different i - it's just a single number, not an array.