所以我使用ggplot2用我的数据制作一个漂亮的小图:
df1 <- data.frame(Background = factor(c("Input", "H3", "Overlap","Input", "H3", "Overlap"), levels=c("Input", "H3", "Overlap")),
Condition = factor(c("control", "control", "control","treatment", "treatment", "treatment")),
Count = c(10, 9, 5, 8, 7, 6))
barplot = ggplot(data=df1, aes(x=Condition, y=Count, fill=Background)) +
geom_bar(position=position_dodge()) +
facet_grid(. ~ Condition)
我想将“控制”与“治疗”区分开来。我有点实现了这一点,但两者仍然在各个小组中表现出来:
如何避免这种情况?
干杯。
答案 0 :(得分:6)
barplot = ggplot(data=df1, aes(x=Background, y=Count, fill=Background)) +
geom_bar(position='dodge') +
facet_grid(.~Condition)