[R] Odp: Plotting densities

Petr PIKAL petr.pikal at precheza.cz
Thu Sep 23 15:17:33 CEST 2010


Hi

r-help-bounces at r-project.org napsal dne 23.09.2010 15:10:04:

> 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?

Something like

lines(density(x2, na.rm = TRUE), col="blue")

Regards
Petr


> 
> Best,
> Ralf
> 
> ______________________________________________
> 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.



More information about the R-help mailing list