Does it only do this while it's charging? If not, have you tested the digitizer to make sure it's not registering some sort of erroneous input? I've seen sketchy chargers cause weird inputs like that on several phones before - I have a desk with built-in USB charging ports that makes any phone I plug into it freak out.
Otherwise I've only seen this when apps are auto-updating in the background on Marshmallow phones and older. Nougat seemed to have fixed it on my 6P since they changed how apps are installed (installing much faster as well).