0

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: enter image description here

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

Community
  • 1
  • 1
Reign of Error
  • 265
  • 1
  • 8
  • Something [like this](http://stackoverflow.com/questions/30196143/bars-in-geom-bar-have-unwanted-different-widths-when-using-facet-wrap)? – Sandy Muspratt May 13 '15 at 11:26
  • Thanks, that dimprove the problem with the widths. Here with the original data I'm working with: http://imgur.com/C9GMgAe. However I would like to retain the grid-like arrangement, as in facets (with blank space on the right of each row where there are – Reign of Error May 13 '15 at 13:22

0 Answers0