【发布时间】:2019-06-21 11:19:19
【问题描述】:
谁能告诉我如何在我的条形图中添加一个图例,它应该只包含一种颜色而不考虑多个组?由于我的图显示了四个不同的组激活了特定数量的调节策略,我只希望图例表明它是图表所有条形的“一般策略使用”表达。
id <- c(1,2,3,4)
group <- c (1,2,3,4)
means <- c(2.57, 2.32, 2.76, 2.61)
sds <- c(0.24, 0.21, 0.26, 0.24)
Problemtype <- c("No Problem", "Motivational Problem", "Knowledge Problem", "Both Problems")
barplot <- ggplot(df, aes(Problemtype, means)) + geom_bar(stat="identity", color="black", fill="lightblue") + geom_errorbar(aes(ymin = means - sds, ymax = means + sds), width=0.2)
barplot + labs(y="Overall Regulation (K 95%)", x = "Problemtype") + theme_classic()
【问题讨论】:
-
您需要将颜色分配放在
aes调用中
标签: r ggplot2 bar-chart legend