ggplot2 - Problem with grid plot
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