Re: [R] ggplot question

From: hadley wickham <h.wickham_at_gmail.com>
Date: Thu, 24 Jul 2008 10:43:29 -0500

On Thu, Jul 24, 2008 at 2:23 AM, Williams Scott <Scott.Williams_at_petermac.org> wrote:
> I am trying to do something simple with ggplot. I wish to draw a density
> plot split by group, and fill each group with a different colour (and
> each with an alpha =0.25). I have tried a number of variations of the
> following, but cannot find a way to define the colour of the fill, its
> transparency and the line around it individually - something in the
> syntax continues to defy me.

To fill each density with a different colour you want:

 + geom_density(aes(fill=group))

I'm not sure what you want to do with the line, but I'm going to guess you want to make it transparent:

 + geom_density(aes(fill=group), colour = NA)

The slightly tricky thing is then making these colours transparent - it's the scale that's responsible for converting data values into shades of colour, so you'll need to change options there:

 + scale_fill_hue(alpha = 0.25)

Does that help?

Hadley

-- 
http://had.co.nz/

______________________________________________
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.
Received on Thu 24 Jul 2008 - 15:53:07 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Thu 24 Jul 2008 - 16:32:11 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive