为geom_line的特定行分配颜色

时间:2019-11-04 20:01:05

标签: r ggplot2

简单地尝试创建一种方法,以便我可以制作12个单独的地块,每个地块都有一个不同的“玩家”为彩色,其余为灰色。我之前已经为geom_bar完成了此操作,但是由于某些原因geom_line我遇到了问题,因为它们全部显示为灰色

mycolors <- c("commish" = "blue","kuney" = "gray78","heets" = 
"gray78","miller" = "gray78","adam" = "gray78","coleman" = 
"gray78","bhupen" = "gray78", "arvin" = "gray78","luke" = "gray78","dad" = 
"gray78","thomas" = "gray78","bery" = "gray78")

ggplot(df, aes(years, pts, fill = player))+
  geom_line(size = 1.2)+
  scale_fill_manual(
    values = mycolors,
    limits = names(mycolors)
  )+
  scale_x_continuous(breaks = c(2010:2019))+
  theme_classic()+
  geom_hline(yintercept = 900)

0 个答案:

没有答案