fixed average calculation and plotting.