Re: [R] ggplot2 - Problem with grid plot

From: hadley wickham <h.wickham_at_gmail.com>
Date: Tue, 04 Mar 2008 07:12:27 -0600

On Tue, Mar 4, 2008 at 6:41 AM, ONKELINX, Thierry <Thierry.ONKELINX_at_inbo.be> 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_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 Tue 04 Mar 2008 - 13:23:10 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 Tue 04 Mar 2008 - 14:00:19 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