Plot improved. Stats calculation function done.