Added plotting the average functionality