Horizontal boxplot and faceting

418 views
Skip to first unread message

Thomas Siegmund

unread,
Apr 8, 2010, 11:00:52 AM4/8/10
to ggplot2
Hi everybody,

first post here, so: Thanks a lot for this cool package!

My question: I have boxplots in a horizontal facet grid. Works fine:

set <- factor(rep(1:3, each=40), labels=c("Compound A","Compound
B","Vehicle"))
animal <- factor(rep(1:6, each=20),
labels=c("T36","T41","T34","T60","T23","T61"))
result <- rnorm(120)
test <- data.frame(set, animal, result)
p <- ggplot(test, aes(animal, result))

p + layer(geom= "boxplot") + facet_grid(. ~ set, space="free",
scales="free_x")

Now I'd like to rotate the layout by 90 degrees to have horizontal
boxplots arranged in a vertical grid, similar to Fig. 7.6 in the
gglpot2 book.

I tried:

p + layer(geom= "boxplot") + coord_flip() + facet_grid(set ~ .,
space="free", scales="free_x");

Now the '"space="free", scales="free_x"' doesn't work any more. Each
facet wastes space for all six animals. Any ideas?

Thanks

Thomas

Bahama

unread,
Apr 13, 2010, 3:55:14 PM4/13/10
to ggplot2
I am having similar problems and would be very interested if you've
resolved this, Thomas. Thanks.

- Bahama

hadley wickham

unread,
Apr 13, 2010, 5:19:24 PM4/13/10
to Thomas Siegmund, ggplot2
Hi Thomas,

The problem is that I've never figured out how free scales and
coordinate systems should interact, and so all coordinate systems
apart from the basic coord_cartesian() cause free scales to be
ignored.

Unfortunately I don't have any bright ideas on how to work around it.

Hadley

> --
> You received this message because you are subscribed to the ggplot2 mailing list.
> To post to this group, send email to ggp...@googlegroups.com
> To unsubscribe from this group, send email to
> ggplot2+u...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/ggplot2
>
> To unsubscribe, reply using "remove me" as the subject.
>

--
Assistant Professor / Dobelman Family Junior Chair
Department of Statistics / Rice University
http://had.co.nz/

Samer MOUKSASSI

unread,
Apr 27, 2015, 5:43:20 PM4/27/15
to ggp...@googlegroups.com, sieg...@develogen.com
Maybe a solution is to have a horizontal boxplot geom. similar to when  an error bar horizontal was later added.

IRich

unread,
Apr 30, 2015, 4:13:39 AM4/30/15
to ggp...@googlegroups.com
Hi Thomas, I just had a thread similar to yours, called "facet x-axis". It works for my problem. Now I have to figure out how to adjust the bar width.

/Inga
Reply all
Reply to author
Forward
0 new messages