OK. You need to start with a "true" histogram, not one of these bastardised frequency diagrams that hist() by itself produces: x <- rlnorm(1000, 1, 1) # for example r <- range(x) d <- dlnorm(r[1]:r[2], meanlog = mean(log(x)), sdlog = sd(log(x))) hist(x, prob = TRUE, ylim = range(d)) lines(r[1]:r[2], d, col="red") You will most likely get a better result if you evaluate your density at (exponentials of) many equally spaced points in the range of log(x). You will also get a much better histogram using truehist(x, ylim = range(d)) where truehist() comes from the MASS library (thanks to BDR). Bill Venables. -----Original Message----- From: Garrett Gman [mailto:grolemun at fas.harvard.edu] Sent: Wednesday, April 09, 2003 5:25 PM To: r-help at stat.math.ethz.ch Subject: [R] plotting the lognormal density curve I am trying to plot a lognormal density curve on top of an existing histogram. Can anybody suggest a simple way to do this? Even if someone could just explain how to plot a regular normal density curve on top of an existing histogram, it would be a big help. Also, is there some way to search through the R-help archives other than simple browsing? Thank you so much. Your help and time is greatly appreciated. ______________________________________________ R-help at stat.math.ethz.ch mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help
plotting the lognormal density curve
1 message · Bill Venables