Re: [R] Highlight overlapping area between two curves
If PDF is OK, you can use the 'alpha' argument in colors, i.e.: pdf( file.pdf) p - seq(0.2,1.4,0.01) x1 - dnorm(p, 0.70, 0.12) x2 - dnorm(p, 0.90, 0.12) plot(range(p), range(x1,x2), type=n) polygon(p, x1, col = rgb(1,0,0, .5),lwd=4, lty=2) polygon(p, x2, col = rgb(0,0,1, .5),lwd=4) dev.off() hth, Michal *** Note that my e-mail address has changed to [EMAIL PROTECTED] *** Please update your address books accordingly. Thank you! _ Michal Bojanowski ICS / Sociology Utrecht University Heidelberglaan 2; 3584 CS Utrecht Room 1428 [EMAIL PROTECTED] http://www.fss.uu.nl/soc/bojanowski -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Nguyen Dinh Nguyen Sent: Tuesday, March 13, 2007 5:20 AM To: r-help@stat.math.ethz.ch Subject: [R] Highlight overlapping area between two curves Dear R helpers, I have a graph as following; I would like to highlight the overlapping area between the two curves. Do you know how to do this? Thank you in advance for your help. Nguyen ###START x1 - rnorm(1, 0.70,0.12) x2 - rnorm(1, 0.90,0.12) d1 - density(x1) d2 - density(x2) plot(range(d1$x,d2$x), range(d1$y, d2$y), type = n, xlab = X value, ylab = Probability Density ) lines(d1, col = red,lwd=4, lty=2) lines(d2, col = blue,lwd=4) ##END CODE __ R-help@stat.math.ethz.ch 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. __ R-help@stat.math.ethz.ch 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.
[R] Highlight overlapping area between two curves
Dear R helpers, I have a graph as following; I would like to highlight the overlapping area between the two curves. Do you know how to do this? Thank you in advance for your help. Nguyen ###START x1 - rnorm(1, 0.70,0.12) x2 - rnorm(1, 0.90,0.12) d1 - density(x1) d2 - density(x2) plot(range(d1$x,d2$x), range(d1$y, d2$y), type = n, xlab = X value, ylab = Probability Density ) lines(d1, col = red,lwd=4, lty=2) lines(d2, col = blue,lwd=4) ##END CODE __ R-help@stat.math.ethz.ch 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.
Re: [R] Highlight overlapping area between two curves
See http://addictedtor.free.fr/graphiques/RGraphGallery.php?graph=7 and code therein. -Christos -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Nguyen Dinh Nguyen Sent: Tuesday, March 13, 2007 12:20 AM To: r-help@stat.math.ethz.ch Subject: [R] Highlight overlapping area between two curves Dear R helpers, I have a graph as following; I would like to highlight the overlapping area between the two curves. Do you know how to do this? Thank you in advance for your help. Nguyen ###START x1 - rnorm(1, 0.70,0.12) x2 - rnorm(1, 0.90,0.12) d1 - density(x1) d2 - density(x2) plot(range(d1$x,d2$x), range(d1$y, d2$y), type = n, xlab = X value, ylab = Probability Density ) lines(d1, col = red,lwd=4, lty=2) lines(d2, col = blue,lwd=4) ##END CODE __ R-help@stat.math.ethz.ch 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. __ R-help@stat.math.ethz.ch 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.
Re: [R] Highlight overlapping area between two curves
On Mar 13, 2007, at 12:19 AM, Nguyen Dinh Nguyen wrote: Dear R helpers, I have a graph as following; I would like to highlight the overlapping area between the two curves. Do you know how to do this? Thank you in advance for your help. Perhaps not exactly what you wanted, but it might give you some ideas: p - seq(0.2,1.4,0.01) x1 - dnorm(p, 0.70, 0.12) x2 - dnorm(p, 0.90, 0.12) plot(range(p), range(x1,x2), type=n) lines(p, x1, col = red,lwd=4, lty=2) lines(p, x2, col = blue,lwd=4) polygon(c(p,p[1]),c(pmin(x1,x2),0), col=grey) Nguyen Haris Skiadas Department of Mathematics and Computer Science Hanover College __ R-help@stat.math.ethz.ch 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.