An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20100711/bfea12e1/attachment.pl>
(no subject)
4 messages · Li Li, Charles C. Berry, Richard M. Heiberger +1 more
On Sun, 11 Jul 2010, li li wrote:
Hi all, I want to add the red color under the standard normal curve to the right of 1.96. Can anyone give me a hand? Please see the code below. Thank you. x <- seq(-4, 4, length=100) hx <- dnorm(x) par(pty="s") plot(x, hx, type="l", xlab="z value", ylab="Density", main="density of N(0,1)") abline(v=1.96, col="red")
?polygon example(polygon)
[[alternative HTML version deleted]]
______________________________________________ R-help at r-project.org mailing list 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.
Charles C. Berry (858) 534-2098
Dept of Family/Preventive Medicine
E mailto:cberry at tajo.ucsd.edu UC San Diego
http://famprevmed.ucsd.edu/faculty/cberry/ La Jolla, San Diego 92093-0901
An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20100711/97755874/attachment.pl>
Here is a way: ### x <- sort(c(seq(-4, 4, length=100), 1.96)) hx <- dnorm(x) par(pty="s") plot(x, hx, type="l", xlab="z value", ylab="Density", main="density of N(0,1)") abline(v=1.96, col="red") abline(h = 0) top <- x >= 1.96 tail <- rbind(cbind(x[top], hx[top]), c(4, 0), c(1.96, 0)) polygon(tail, col = "red") ### As the guidelines say, please put a suitable subject line on your queries. These messages are archived for future reference by others. It makes it impossible to find appropriate messages if there is no subject to give a clue on what it is all about. -----Original Message----- From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On Behalf Of li li Sent: Monday, 12 July 2010 1:22 PM To: r-help Subject: [R] (no subject) Hi all, I want to add the red color under the standard normal curve to the right of 1.96. Can anyone give me a hand? Please see the code below. Thank you. x <- seq(-4, 4, length=100) hx <- dnorm(x) par(pty="s") plot(x, hx, type="l", xlab="z value", ylab="Density", main="density of N(0,1)") abline(v=1.96, col="red") ______________________________________________ R-help at r-project.org mailing list 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.