Roberto
unread,Sep 2, 2009, 4:08:30 PM9/2/09Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to ggplot2
I'm trying again since I got no response to the message titled "Scales
and space in faceting".
Is there a way to have individual control for the panel heights in
faceting? I could use such a feature since I get unpredictable
behavior when using scales="free", space="free".
According to the documentation in Chapter 7,
"For facet_grid there is an additional parameter called space, which
takes values "free" or "fixed". When the space can vary freely, each
column (or row) will have width (or height) proportional to the range
of the scale for that column (or row)."
It seems to work as documented when space = "free" and scales =
"fixed" (in this case the same scale is used in all panels) but not
when scales = "free". Take the following example:
da <- data.frame(
x=rep(1:5, 2),
y=c(1+(0:4), 1+(0:4)/10),
z=rep(1:2, each=5))
da
# x y z
#1 1 1.0 1
#2 2 2.0 1
#3 3 3.0 1
#4 4 4.0 1
#5 5 5.0 1
#6 1 1.0 2
#7 2 1.1 2
#8 3 1.2 2
#9 4 1.3 2
#10 5 1.4 2
qplot(x, y, data=da, group=z, geom="line") +
# scale_y_log10() +
facet_grid(z~., scales="free_y", space="free")
If the facet heights were proportional to their row ranges, the ratio
of the top to bottom facet heights (i.e., z=1 to z=2) would be (5-1)/
(1.4-1) = 4/0.4 = 10. The observed ratio in the resulting plot is
instead a lot smaller than that.
If you uncomment the line with scale_y_log10() the heights ratio would
be log10(5)/log10(1.4) (since log10(1) = 0), i.e., 4.78. In reality,
the two panel heights look the same in my display!
I'm using R 2.9.1 and ggplot2 0.8.3.
Roberto