[R] Highlight overlapping area between two curves
Nguyen Dinh Nguyen
n.nguyen at garvan.org.au
Tue Mar 13 05:19:58 CET 2007
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(10000, 0.70,0.12)
x2 <- rnorm(10000, 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
More information about the R-help
mailing list