[R] ggplot2 boxplot confusion

Chris Friedl cfriedalek at gmail.com
Thu Feb 28 00:09:41 CET 2008


Hi Hadley

First off, thanks for ggplot2 and everything that bringing it to life and
sustaining it entails.

I noticed the coord flip problem during my ggplot investigations. Is this
something I can override by getting into the code?

On the coord flipping problem I was thinking to grab the density data
explicitly, swap x and y and then plot as a scatter plot with a box plot
overlaid.

Or perhaps just draw the density plots with vertical lines drawn at the
median, IQR etc 

Or perhaps draw the density plots and fake a boxplot by drawing bars
explicitly.

I'm hoping you can at least advise which of any of these routes is likely to
be a dead end.

regards

Chris





hadley wrote:
> 
>>  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.
> 
> Hadly
> 
> -- 
> http://had.co.nz/
> 
> 

-- 
View this message in context: http://www.nabble.com/ggplot2-boxplot-confusion-tp15706116p15725753.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list