I want like to represent values (bars, in this case) within facets for a set of ~30 items which fall into five variably sized super-groups. The contrasts between groups are interesting, so I'd like to show each group as a strip. So far:
example <- data.frame(class=rep(c("I", "I", "I", "II", "II"), 2),
unit=rep(letters[1:5], 2),
variable=rep(c("var1", "var2"), 5),
value=rnorm(10))
ggplot(example, aes(x=unit, y=value, fill=variable)) +
geom_bar(stat="identity", position="dodge") +
facet_wrap(~class, scales="free_x", ncol=1)
This produces something like this:
The problem is that with "free_x" scales, the width of the bars in each facet varies according to the number of items in that group. Without "free_x", all items are shown in all facets.
The question is similar to this: Nested facet plot with ggplot2