Each loop does a single acquisition, that is averaged n times. Only the result, obtained after the nth acquisition is valid. During intermediate calculations, an empty array is returned. That's why the graph is emptied. A moving average would have been more suitable.
CC
Chilly Charly (aka CC)