Skip to content
Back to formatted view

Raw Message

Message-ID: <f8e6ff050803040512p2b6d1bcdufe60dde3466fe6a6@mail.gmail.com>
Date: 2008-03-04T13:12:27Z
From: Hadley Wickham
Subject: ggplot2 - Problem with grid plot
In-Reply-To: <2E9C414912813E4EB981326983E0A104046D0974@inboexch.inbo.be>

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/