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
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 guidehttp://www.R-project.org/posting-guide.html> and provide commented, minimal, self-contained, reproducible code.
In your call to polygon(), include lty="dashed" or "dotted" or whatever you want your line type to look like. take a good look at all the options in ?par For everything you can customize in plots. Alternatively, Paul Murrel's R Graphics book is the best reference I know for this sort of stuff. Mike On Thu, Sep 23, 2010 at 8:10 AM, Ralf B <ralf.bierig@gmail.com> wrote:> 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 > > ______________________________________________ > R-help@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<http://www.r-project.org/posting-guide.html> > and provide commented, minimal, self-contained, reproducible code. >[[alternative HTML version deleted]]