errorBar <- ggplot(ErrorAnalDF, aes(Task, ErrorPer, colour = Position))
errorBar + stat_summary(fun.y = mean, geom = "bar", position = "dodge", fill = "blue") +
stat_summary(fun.data = mean_cl_normal, geom = "errorbar", position = position_dodge(width = 0.90), width = 0.2) +
labs(x = "Task", y = "Error Percentage") + facet_wrap(~MuBack)
如何为Head和Tail的条形填充(蓝色)获得不同的颜色,就像我对错误条和边框一样?
我试过errorBar + stat_summary(fun.y = mean, geom = "bar", position = "dodge", fill = c("red","blue")
或者添加填充labs(x = "Task", y = "Error Percentage", fill="Position")
//编辑:使用fill
代替colour
errorBar <- ggplot(ErrorAnalDF, aes(Task, ErrorPer, fill = Position))
答案 0 :(得分:2)
在第一个fill=
和stat.summary
使用ggplot(..., aes())
而不是fill = position
colour = position
errorBar <- ggplot(ErrorAnalDF, aes(Task, ErrorPer, fill = Position))
errorBar + stat_summary(fun.y = mean, geom = "bar", position = "dodge") +
stat_summary(fun.data = mean_cl_normal, geom = "errorbar", position = position_dodge(width = 0.90), width = 0.2) +
labs(x = "Task", y = "Error Percentage") + facet_wrap(~MuBack)