I would like to plot this data frame with a barplot :
df <- data.frame(x = rep(c("x1", "x2"), each = 4L),
f = rep(c("f1", "f2"), each = 2L, times = 2L),
c = rep(c("c1", "c2"), 4L),
y = c(rbind(seq(0.1, 0.4, by = 0.1), 1 - seq(0.1, 0.4, by = 0.1))))
I would like to dodge the bars for distinct fill values but also keep them stacked for the same fill values, when it's just the color value which is different.
library(ggplot2)
ggplot(df, aes(x = x,
y = y,
fill = f,
color = c)) +
geom_col(position = "dodge")
So in this case all bars would be stacked to 1 with distinct "color" in it.
Do you have any idea on how I can achieve this ? I would like to avoid faceting.
Thank You !