我想使用scale_color_manual函数手动更改ggplot条形图的颜色。这是代码:
library(ggplot2)
ggplot(UM.Leads, aes(Leads, Count, fill = Model)) +
geom_bar(stat = "identity") +
xlab("Electrode Model") +
ylab("DBS Leads") +
ggtitle("University of Minnesota") +
scale_color_manual(values = c("darkgoldenrod1", "grey55", "dodgerblue1")) +
theme_classic()
我似乎无法更改ggplot提供的默认粉色,绿色和蓝色条形图的填充。任何帮助将不胜感激!
请参见此处的情节:http://rpubs.com/Gopher16/393415
答案 0 :(得分:0)
为了说明@Jack Brookes的评论并创建一个可重现的例子:
library(ggplot2)
df <- data.frame(
gp = factor(rep(letters[1:3], each = 10)),
y = rnorm(30)
)
ggplot(df, aes(gp, y, fill=gp)) +
geom_bar(stat = "identity") +
scale_fill_manual(values = c("darkgoldenrod1", "grey55", "dodgerblue1")) +
theme_classic()