I want to: (a) Reduce space between P1 and P2 (I tried position.dodge as suggested by others but no luck there) (b) Reduce space between the organs "A","B" and "C",
organ <- c("A","A","A","A","B","B","B","B","C","C","C","C")
val <- c(1,1,0,0,1,1,0,0,1,1,0,0)
plant <- c("P1","P2","P2","P1","P1","P2","P2","P1","P1","P2","P2","P1")
order <- c("P1 first","P2 first","P1 first","P2 first","P1 first","P2 first","P1 first","P2 first","P1 first","P2 first","P1 first","P2 first")
df <- data.frame(organ,val,plant,order)
ggplot(aes(x = plant, y= val, color = plant, fill=plant), data = df) +
geom_bar(stat='identity', width = 0.3,position = position_dodge(width = 100)) +
facet_grid(order~organ) + theme(legend.position = "none") +
theme_classic()