tunnuz
tunnuz

Reputation: 24038

How to force showing of empty plots with ggplot2 facets?

I am producing box plots for two data sets in R + ggplot2 and I'm using facets to print a grid of plots based on two factors. So far so good, the point is that one of the two data sets is completely missing values for one of the levels of one factor, hence I get a grid of 5 x 5 and a grid of 5 x 4, but these grid are meant to be eye-compared, and thus I would like to show the empty plots for the missing values. Is that possible?

Thanks, Tommaso

Upvotes: 5

Views: 4852

Answers (1)

joran
joran

Reputation: 173737

To quote the documentation at ?facet_grid:

drop: If TRUE, the default, all factor levels not used in the data will automatically be dropped. If FALSE, all factor levels will be shown, regardless of whether or not they appear in the data.

so maybe drop = FALSE?

Upvotes: 11

Related Questions