On Tue, Mar 4, 2008 at 6:41 AM, ONKELINX, Thierry
<[EMAIL PROTECTED]> wrote:
> Dear Chris,
>
>  You'll need to add information on the facet factor (color) to the
>  medians dataset.
>
>  library(ggplot2)
>  medians <- aggregate(diamonds$price, list(cut = diamonds$cut, color =
>  diamonds$color), median)
>  ggplot(data=diamonds, aes(x=price)) + geom_density(aes(color=cut)) +
>  geom_vline(data=medians, aes(color=cut, intercept = x)) +
>  facet_grid(color~.)

Or in the next version of ggplot, you'll be able to do

ggplot(data=diamonds, aes(x=price, colour=cut)) + geom_density() +
geom_vline( intercept = "median") + facet_grid(color~.)

It should be out in the next week or so.

Hadley

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

______________________________________________
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
and provide commented, minimal, self-contained, reproducible code.

Reply via email to