Re: [R] label outliers in geom_boxplot (ggplot2)

From: hadley wickham <>
Date: Fri, 06 Jun 2008 10:36:30 -0500

> It's too obvious, so I am positive that there is a good reason for not doing
> this, but still:
> why is it not possible, to have an "outlier" output in stat_boxplot that can
> be used at geom_text()?
> Something like this, with "upper":
> > dat=data.frame(num=rep(1,20), val=c(runif(18),3,3.5),
> name=letters[1:20])
> > ggplot(dat, aes(y=val, x=num))+stat_boxplot(outlier.size=4,
> + outlier.colour="green")+geom_text(aes(y=..upper..), label="This is upper
> hinge")
> Unfortunately, this does not work and gives the error message:
> Error in eval(expr, envir, enclos) : object "upper" not found
> Is it because you can only use stat outputs within the stat statements?
> Could it be possible to make them available outside the statements too?

You can generally, but it won't work here. The problem is that you want a different y aesthetic for the statistic (val) than you do for the geom (upper) and there's no way to get around that with the current design of ggplot2.



______________________________________________ mailing list
PLEASE do read the posting guide
and provide commented, minimal, self-contained, reproducible code.
Received on Fri 06 Jun 2008 - 17:56:58 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 Fri 06 Jun 2008 - 18:30:37 GMT.

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

list of date sections of archive