geom and stat boxplot : change lower and upper whisker (ymin and ymax)

49 views
Skip to first unread message

David Hajage

unread,
Jun 8, 2009, 11:39:05 AM6/8/09
to ggplot2
Hello,

I would like to change the default value of the lower and upper whiskers in a boxplot (from lower/upper hinge -/+ 1.5 * IQR to quantile 0.1 and 0.9).

Is there an easy way ? Or must I write my own stat_boxplot ?

Thank you very much.

hadley wickham

unread,
Jun 8, 2009, 11:48:59 AM6/8/09
to David Hajage, ggplot2

There is no easy way, basically because I'm of the strong believe that
that is not a boxplot. I agree it's a useful plot in some
circumstances, but I think it's misleading to display it in the same
way as a boxplot.

An alternative would be this:

d1 <- function(x) unname(quantile(x, 0.1))
d9 <- function(x) unname(quantile(x, 0.9))

ggplot(mpg, aes(model, cty)) +
geom_crossbar(stat = "summary", fun.y = median, fun.ymin = d1,
fun.ymax = d9) +
geom_point() +
coord_flip()

Hadley

--
http://had.co.nz/

Reply all
Reply to author
Forward
0 new messages