[R] Plotting densities

Ralf B ralf.bierig at gmail.com
Thu Sep 23 15:10:04 CEST 2010


Hi group,

I am currently plotting two densities using the following code:

x1 <- c(1,2,1,3,5,6,6,7,7,8)
x2 <- c(1,2,1,3,5,6,5,7)
plot(density(x1, na.rm = TRUE))
polygon(density(x2, na.rm = TRUE), border="blue")

However, I would like to avoid bordering the second density as it adds
a nasty bottom line which I would like to avoid.
I would also rather have a dashed or dotted line for the second
(currently blue) density but without the bottom part.
Any idea how to do that?

Best,
Ralf



More information about the R-help mailing list