所以我使用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)
Run Code Online (Sandbox Code Playgroud)
我想把"控制"与"治疗"分开.我有点实现了这一点,但两者仍然在各个小组中表现出来:
怎么避免这个?
干杯.
泰勒的评论是一个解决方案.但为什么将facet变量绘制为x变量?相反,我会使用Background作为你的x.
barplot = ggplot(data=df1, aes(x=Background, y=Count, fill=Background)) +
geom_bar(position='dodge') +
facet_grid(.~Condition)
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
226 次 |
最近记录: |