AbouEl-Makarim Aboueissa
2017-Sep-24 23:35 UTC
[R] Shift the normal curve to the top or near to the top of the histogram
Dear All: One more thing. I want to add the normal curve to the histogram. Is there away to stretch the peak of the curve to the top of the histogram or at least near to the top of the histogram. Please see the code below. Lizard.tail.lengths <- c(6.2, 6.6, 7.1, 7.4, 7.6, 7.9, 8, 8.3, 8.4, 8.5, 8.6,8.8, 8.8, 9.1, 9.2, 9.4, 9.4, 9.7, 9.9, 10.2, 10.4, 10.8,11.3, 11.9) x<-seq(5,12, 0.001) hist(Lizard.tail.lengths, main = "Normal Probability Plot of Lizard Tail Lengths") curve(dnorm(x ,mean=mean(Lizard.tail.lengths),sd=sd(Lizard.tail.lengths)), add=TRUE, col=2, lwd = 2) with many thanks abou ______________________ AbouEl-Makarim Aboueissa, PhD Professor of Statistics Department of Mathematics and Statistics University of Southern Maine [[alternative HTML version deleted]]
Jim Lemon
2017-Sep-25 00:18 UTC
[R] Shift the normal curve to the top or near to the top of the histogram
Hi Abou, Try this: library(plotrix) curve(rescale(dnorm(x ,mean=mean(Lizard.tail.lengths),sd=sd(Lizard.tail.lengths)), c(0,6)),add=TRUE, col=2, lwd = 2) Jim On Mon, Sep 25, 2017 at 9:35 AM, AbouEl-Makarim Aboueissa <abouelmakarim1962 at gmail.com> wrote:> Dear All: > > One more thing. > > I want to add the normal curve to the histogram. Is there away to stretch > the peak of the curve to the top of the histogram or at least near to the > top of the histogram. > > Please see the code below. > > > Lizard.tail.lengths <- c(6.2, 6.6, 7.1, 7.4, 7.6, 7.9, 8, 8.3, 8.4, 8.5, > 8.6,8.8, 8.8, 9.1, 9.2, 9.4, 9.4, 9.7, 9.9, 10.2, 10.4, 10.8,11.3, 11.9) > > x<-seq(5,12, 0.001) > > hist(Lizard.tail.lengths, main = "Normal Probability Plot of Lizard Tail > Lengths") > > curve(dnorm(x ,mean=mean(Lizard.tail.lengths),sd=sd(Lizard.tail.lengths)), > add=TRUE, col=2, lwd = 2) > > > > with many thanks > abou > ______________________ > AbouEl-Makarim Aboueissa, PhD > Professor of Statistics > Department of Mathematics and Statistics > University of Southern Maine > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code.
AbouEl-Makarim Aboueissa
2017-Sep-25 00:26 UTC
[R] Shift the normal curve to the top or near to the top of the histogram
Dear Jim: Thank you very much abou On Sun, Sep 24, 2017 at 8:18 PM, Jim Lemon <drjimlemon at gmail.com> wrote:> Hi Abou, > Try this: > > library(plotrix) > curve(rescale(dnorm(x > ,mean=mean(Lizard.tail.lengths),sd=sd(Lizard.tail.lengths)), > c(0,6)),add=TRUE, col=2, lwd = 2) > > Jim > > > On Mon, Sep 25, 2017 at 9:35 AM, AbouEl-Makarim Aboueissa > <abouelmakarim1962 at gmail.com> wrote: > > Dear All: > > > > One more thing. > > > > I want to add the normal curve to the histogram. Is there away to stretch > > the peak of the curve to the top of the histogram or at least near to the > > top of the histogram. > > > > Please see the code below. > > > > > > Lizard.tail.lengths <- c(6.2, 6.6, 7.1, 7.4, 7.6, 7.9, 8, 8.3, 8.4, 8.5, > > 8.6,8.8, 8.8, 9.1, 9.2, 9.4, 9.4, 9.7, 9.9, 10.2, 10.4, 10.8,11.3, 11.9) > > > > x<-seq(5,12, 0.001) > > > > hist(Lizard.tail.lengths, main = "Normal Probability Plot of Lizard Tail > > Lengths") > > > > curve(dnorm(x ,mean=mean(Lizard.tail.lengths),sd=sd(Lizard.tail. > lengths)), > > add=TRUE, col=2, lwd = 2) > > > > > > > > with many thanks > > abou > > ______________________ > > AbouEl-Makarim Aboueissa, PhD > > Professor of Statistics > > Department of Mathematics and Statistics > > University of Southern Maine > > > > [[alternative HTML version deleted]] > > > > ______________________________________________ > > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see > > https://stat.ethz.ch/mailman/listinfo/r-help > > PLEASE do read the posting guide http://www.R-project.org/ > posting-guide.html > > and provide commented, minimal, self-contained, reproducible code. >-- ______________________ AbouEl-Makarim Aboueissa, PhD Professor of Statistics Department of Mathematics and Statistics University of Southern Maine [[alternative HTML version deleted]]
Rui Barradas
2017-Sep-25 10:00 UTC
[R] Shift the normal curve to the top or near to the top of the histogram
Hello, Try using hist argument 'prob = TRUE' or, which is equivalent, 'freq = FALSE'. hist(..., prob = TRUE) # or hist(..., freq = FALSE) This is because like this you will have a density, comparable to a parametric density. Note that the peak of the normal will be outside the plot area so you will have to adjust the plot area dimensions. In this case I've set 'ylim = c(0, 0.35)'. hist(Lizard.tail.lengths, main = "Normal Probability Plot of Lizard Tail Lengths", ylim = c(0, 0.35), prob = TRUE) curve(dnorm(x ,mean=mean(Lizard.tail.lengths),sd=sd(Lizard.tail.lengths)), add=TRUE, col=2, lwd = 2) Hope this helps, Rui Barradas Em 25-09-2017 00:35, AbouEl-Makarim Aboueissa escreveu:> Dear All: > > One more thing. > > I want to add the normal curve to the histogram. Is there away to stretch > the peak of the curve to the top of the histogram or at least near to the > top of the histogram. > > Please see the code below. > > > Lizard.tail.lengths <- c(6.2, 6.6, 7.1, 7.4, 7.6, 7.9, 8, 8.3, 8.4, 8.5, > 8.6,8.8, 8.8, 9.1, 9.2, 9.4, 9.4, 9.7, 9.9, 10.2, 10.4, 10.8,11.3, 11.9) > > x<-seq(5,12, 0.001) > > hist(Lizard.tail.lengths, main = "Normal Probability Plot of Lizard Tail > Lengths") > > curve(dnorm(x ,mean=mean(Lizard.tail.lengths),sd=sd(Lizard.tail.lengths)), > add=TRUE, col=2, lwd = 2) > > > > with many thanks > abou > ______________________ > AbouEl-Makarim Aboueissa, PhD > Professor of Statistics > Department of Mathematics and Statistics > University of Southern Maine > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >