[R] ggplot2 - Problem with grid plot
hadley wickham
h.wickham at gmail.com
Tue Mar 4 14:12:27 CET 2008
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/
More information about the R-help
mailing list