I want to compare data in a facet-alike manner using a bar plot, but missing data causes the bar "widths" to be different:
How can I
- ensure the same bar size ("width") and
- [nice to have] shrink the panel size of each facet to the really required size?
PS: I do not want to show empty data as "zero-bar" to waste no space.
library(ggplot2)
data <- data.frame(product = c("Fish", "Chips", "Baguette"),
store = c("London", "London", "Paris"),
customer.satisfaction = c(0.9, 0.95, 0.8),
stringsAsFactors = TRUE)
data
ggplot(data, aes(x = product, y = customer.satisfaction)) +
geom_bar(stat = "identity", width = 0.9) +
coord_flip() +
facet_wrap( ~ store, ncol = 1, scales = "free_y")