This is basically the same question this one, but with one important difference: I want a ggplot2-based tile plot with horizontal panels, and where all of the tiles are of equal height. The other question was about vertical panels.
Here’s some example code, based on the one in the other question:
d = data.frame(sites=rep(paste("S", 1:31),each=12),
month=factor(rep(1:12,31)),
value=runif(31*12),
panel=c(rep("Group 1",16*12), rep("Group 2", 12*12),
rep("Group 3", 3*12)))
Plotting this using
ggplot(d, aes(x=month, y=sites, fill=value)) +
geom_tile(colour="white") + facet_wrap(~panel, nrow=1)
results in
Basically, I want each block of blue tiles moved up, so that there is no space above them. I can achieve this using
ggplot(d, aes(x=month, y=sites, fill=value, colour="white")) +
geom_tile(colour="white") + facet_wrap(~panel, scales="free_y", nrow=1)
but this results in tiles of unequal height:
The other question had a nice solution for vertical panels, but applying this to the above code has no effect. Is there a similar solution for horizontal panels?