removed duplicated plotting code. use pure least-squares fit rather than pin the max of the gaussians