I have the following bar plot that has four groups within each level. However, some of the groups have a count of zero in some levels. I'd like to have it so that there is an empty space for those zero values in my bar plot; essentially have a bar with height = 0.
data %>%
ggplot(aes(x = major, fill = year)) +
geom_bar(position = position_dodge(preserve = "single"), color = "white") +
scale_y_continuous(breaks = seq(0, 9, 1)) +
xlab("xlab") +
ylab("yalb") +
scale_fill_brewer(palette = "Set2", name = "Legend")
I've looked at similar questions that were posted but none of them have solutions that work for me. I tried preserve = "single"
for position_dodge()
but that doesn't do anything.