Re: [R] ggplot2 boxplot confusion

From: hadley wickham <>
Date: Wed, 27 Feb 2008 09:10:00 -0600

> Now I think I understand want you want. I'm affraid that won't be easy
> because you're trying to mix continuous variables with categorical ones
> on the same scale. A density plot has two continuous scales: VALUE and
> it's density. The boxplot has a continuous scale (VALUE) and the other
> is categorical. Maybe Hadley knows a solution for your problem.

Well one idea is:

ggplot(diamonds, aes(x = price)) + geom_density(aes(min = -..density.., adjust= 0.5),fill="grey50", colour=NA) + facet_grid(. ~ cut) + coord_flip()

which looks like it would naturally fit with a boxplot overlaid on top of it. However, it's currently not possible because the boxplot is parameterised so that it is always horizontal, while the density is vertical - in the above example I have flipped the coordinate system, but that flips both density plot and boxplot.



______________________________________________ mailing list
PLEASE do read the posting guide
and provide commented, minimal, self-contained, reproducible code.
Received on Wed 27 Feb 2008 - 15:13:07 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 Wed 27 Feb 2008 - 23:30:19 GMT.

Mailing list information is available at Please read the posting guide before posting to the list.

list of date sections of archive