R:箱线图填充了 "label" 颜色

R: Boxplot filled with its "label" color

我想用它的颜色填充框(例如:蓝色 -> 蓝色)。

goo1 <- ggplot(dataset1, aes(x=Color, y=Scored.Probabilities)) +
geom_boxplot() +
stat_summary(fun.y = mean, geom="point",colour="darkred", size=3) +
stat_summary(fun.data = fun_mean, geom="text", vjust=-0.7)
print (goo1)

数据可以在这里找到:link

添加一个刻度(虽然你需要首先确保 dataset1$Persons 的每个级别确实是 R 识别的颜色名称;目前, darkgame value 是不)

colors <- levels(dataset1$Color)
colors[colors == "dark"] <- "black"
colors[colors == "game value"] <- "cyan"

goo2 <- ggplot(dataset1, aes(x=Color, y=Scored.Probabilities)) +
  geom_boxplot(aes(fill=Color)) +
  stat_summary(fun.y = mean, geom="point",colour="darkred", size=3)

goo2 <- goo2 + scale_fill_manual(values=colors)