改变每个面中最大条的颜色

时间:2016-12-15 21:19:57

标签: r ggplot2

我试图为每个方面(这里,每个玩家)的最大条形颜色与其他方形不同。相反,下面的代码会为所有方面的最大条形颜色添加颜色。我该如何解决这个问题?

require(dplyr)
require(ggplot2)
require(ggthemes)

    df %>% 
      group_by(Player, Theme) %>% summarise(Likes = mean(fb_Likes)) %>%
      ggplot(aes(x = Theme, y = Likes), color = "white") + 
      geom_bar(stat = "identity", aes(group = Player, fill = Likes == max(Likes))) +
      scale_fill_manual(values = c('#888888', '#333333') ) +
      theme_tufte(base_size = 12, 
                  base_family = "sans", 
                  ticks = TRUE) + 
      coord_flip() +   
      theme(legend.position = "none", panel.background = element_blank()) +
      facet_grid(Player ~., space = "free")

以下是数据:

df <- structure(list(Player = c("Ozil", "Ozil", "Ozil", "Ozil", "Ozil", 
"Ozil", "Ozil", "Ozil", "Ozil", "Ozil", "Ozil", "Ozil", "Ozil", 
"Ozil", "Ozil", "Ozil", "Ozil", "Ozil", "Ozil", "Ozil", "Ozil", 
"Ozil", "Ozil", "Ozil", "Ozil", "Ozil", "Ozil", "Ozil", "Ozil", 
"Ozil", "Ozil", "Ozil", "Ozil", "Ozil", "Ozil", "Ozil", "Ozil", 
"Ozil", "Ozil", "Ozil", "Ozil", "Ozil", "Ozil", "Ozil", "Ozil", 
"Ozil", "Ozil", "Ozil", "Ozil", "Ozil", "Ozil", "Ozil", "Ozil", 
"Ozil", "Ozil", "Ozil", "Ozil", "Ozil", "Ozil", "Ozil", "Ozil", 
"Ozil", "Ozil", "Ozil", "Ozil", "Ozil", "Ozil", "Ozil", "Ozil", 
"Ozil", "Ozil", "Ozil", "Ozil", "Ozil", "Ozil", "Ronaldo", "Ronaldo", 
"Ronaldo", "Ronaldo", "Ronaldo", "Ronaldo", "Ronaldo", "Ronaldo", 
"Ronaldo", "Ronaldo", "Ronaldo", "Ronaldo", "Ronaldo", "Ronaldo", 
"Ronaldo", "Ronaldo", "Ronaldo", "Ronaldo", "Ronaldo", "Ronaldo", 
"Ronaldo", "Ronaldo", "Ronaldo", "Ronaldo", "Ronaldo", "Ronaldo", 
"Ronaldo", "Ronaldo", "Ronaldo", "Ronaldo", "Ronaldo", "Ronaldo", 
"Ronaldo", "Ronaldo", "Ronaldo", "Ronaldo", "Ronaldo", "Ronaldo", 
"Ronaldo", "Ronaldo", "Ronaldo", "Ronaldo", "Ronaldo", "Ronaldo", 
"Ronaldo", "Ronaldo", "Ronaldo", "Ronaldo", "Ronaldo", "Ronaldo", 
"Ronaldo", "Ronaldo", "Ronaldo", "Ronaldo", "Ronaldo", "Ronaldo", 
"Ronaldo", "Ronaldo", "Ronaldo", "Ronaldo", "Ronaldo", "Ronaldo", 
"Ronaldo", "Ronaldo", "Ronaldo", "Ronaldo", "Ronaldo", "Ronaldo", 
"Ronaldo", "Ronaldo", "Ronaldo", "Ronaldo", "Ronaldo", "Ronaldo", 
"Ronaldo", "Neymar", "Neymar", "Neymar", "Neymar", "Neymar", 
"Neymar", "Neymar", "Neymar", "Neymar", "Neymar", "Neymar", "Neymar", 
"Neymar", "Neymar", "Neymar", "Neymar", "Neymar", "Neymar", "Neymar", 
"Neymar", "Neymar", "Neymar", "Neymar", "Neymar", "Neymar", "Neymar", 
"Neymar", "Neymar", "Neymar", "Neymar", "Neymar", "Neymar", "Neymar", 
"Neymar", "Neymar", "Neymar", "Neymar", "Neymar", "Neymar", "Neymar", 
"Neymar", "Neymar", "Neymar", "Neymar", "Neymar", "Neymar", "Neymar", 
"Neymar", "Neymar", "Neymar", "Neymar", "Neymar", "Neymar", "Neymar", 
"Neymar", "Neymar", "Neymar", "Neymar", "Neymar", "Neymar", "Neymar", 
"Neymar", "Neymar", "Neymar", "Neymar", "Neymar", "Neymar", "Neymar", 
"Neymar", "Neymar", "Neymar", "Neymar", "Neymar", "Neymar", "Neymar", 
"Bale", "Bale", "Bale", "Bale", "Bale", "Bale", "Bale", "Bale", 
"Bale", "Bale", "Bale", "Bale", "Bale", "Bale", "Bale", "Bale", 
"Bale", "Bale", "Bale", "Bale", "Bale", "Bale", "Bale", "Bale", 
"Bale", "Bale", "Bale", "Bale", "Bale", "Bale", "Bale", "Bale", 
"Bale", "Bale", "Bale", "Bale", "Bale", "Bale", "Bale", "Bale", 
"Bale", "Bale", "Bale", "Bale", "Bale", "Bale", "Bale", "Bale", 
"Bale", "Bale", "Bale", "Bale", "Bale", "Bale", "Bale", "Bale", 
"Bale", "Bale", "Bale", "Bale", "Bale", "Bale", "Bale", "Bale", 
"Bale", "Bale", "Bale", "Bale", "Bale", "Bale", "Bale", "Bale", 
"Bale", "Bale", "Bale", "Pogba", "Pogba", "Pogba", "Pogba", "Pogba", 
"Pogba", "Pogba", "Pogba", "Pogba", "Pogba", "Pogba", "Pogba", 
"Pogba", "Pogba", "Pogba", "Pogba", "Pogba", "Pogba", "Pogba", 
"Pogba", "Pogba", "Pogba", "Pogba", "Pogba", "Pogba", "Pogba", 
"Pogba", "Pogba", "Pogba", "Pogba", "Pogba", "Pogba", "Pogba", 
"Pogba", "Pogba", "Pogba", "Pogba", "Pogba", "Pogba", "Pogba", 
"Pogba", "Pogba", "Pogba", "Pogba", "Pogba", "Pogba", "Pogba", 
"Pogba", "Pogba", "Pogba", "Pogba", "Pogba", "Pogba", "Pogba", 
"Pogba", "Pogba", "Pogba", "Pogba", "Pogba", "Pogba", "Pogba", 
"Pogba", "Pogba", "Pogba", "Pogba", "Pogba", "Pogba", "Pogba", 
"Pogba", "Pogba", "Pogba", "Pogba", "Pogba", "Pogba", "Pogba", 
"Suarez", "Suarez", "Suarez", "Suarez", "Suarez", "Suarez", "Suarez", 
"Suarez", "Suarez", "Suarez", "Suarez", "Suarez", "Suarez", "Suarez", 
"Suarez", "Suarez", "Suarez", "Suarez", "Suarez", "Suarez", "Suarez", 
"Suarez", "Suarez", "Suarez", "Suarez", "Suarez", "Suarez", "Suarez", 
"Suarez", "Suarez", "Suarez", "Suarez", "Suarez", "Suarez", "Suarez", 
"Suarez", "Suarez", "Suarez", "Suarez", "Suarez", "Suarez", "Suarez", 
"Suarez", "Suarez", "Suarez", "Suarez", "Suarez", "Suarez", "Suarez", 
"Suarez", "Suarez", "Suarez", "Suarez", "Suarez", "Suarez", "Suarez", 
"Suarez", "Suarez", "Suarez", "Suarez", "Suarez", "Suarez", "Suarez", 
"Suarez", "Suarez", "Suarez", "Suarez", "Suarez", "Suarez", "Suarez", 
"Suarez", "Suarez", "Suarez", "Suarez"), Theme = c("02 Personal", 
"05 Onfield Performance", "05 Onfield Performance", "03 Sponsorship", 
"05 Onfield Performance", "09 Off-field Responsibilities", "04 Pop Culture", 
"02 Personal", "05 Onfield Performance", "10 Other Athletes", 
"03 Sponsorship", "05 Onfield Performance", "05 Onfield Performance", 
"09 Off-field Responsibilities", "11 Other", "03 Sponsorship", 
"11 Other", "02 Personal", "05 Onfield Performance", "10 Other Athletes", 
"05 Onfield Performance", "09 Off-field Responsibilities", "11 Other", 
"05 Onfield Performance", "09 Off-field Responsibilities", "07 Politics", 
"03 Sponsorship", "06 Shoutout", "08 Throwback", "09 Off-field Responsibilities", 
"09 Off-field Responsibilities", "11 Other", "05 Onfield Performance", 
"02 Personal", "09 Off-field Responsibilities", "10 Other Athletes", 
"10 Other Athletes", "02 Personal", "05 Onfield Performance", 
"02 Personal", "08 Throwback", "05 Onfield Performance", "10 Other Athletes", 
"10 Other Athletes", "10 Other Athletes", "05 Onfield Performance", 
"11 Other", "11 Other", "09 Off-field Responsibilities", "08 Throwback", 
"11 Other", "02 Personal", "02 Personal", "10 Other Athletes", 
"09 Off-field Responsibilities", "10 Other Athletes", "02 Personal", 
"09 Off-field Responsibilities", "02 Personal", "10 Other Athletes", 
"02 Personal", "02 Personal", "10 Other Athletes", "10 Other Athletes", 
"08 Throwback", "02 Personal", "05 Onfield Performance", "09 Off-field Responsibilities", 
"09 Off-field Responsibilities", "02 Personal", "02 Personal", 
"09 Off-field Responsibilities", "10 Other Athletes", "05 Onfield Performance", 
"09 Off-field Responsibilities", "03 Sponsorship", "03 Sponsorship", 
"02 Personal", "00 Upcoming Season", "03 Sponsorship", "03 Sponsorship", 
"02 Personal", "02 Personal", "02 Personal", "05 Onfield Performance", 
"03 Sponsorship", "02 Personal", "02 Personal", "03 Sponsorship", 
"03 Sponsorship", "03 Sponsorship", "02 Personal", "00 Upcoming Season", 
"00 Upcoming Season", "01 Charities", "02 Personal", "02 Personal", 
"00 Upcoming Season", "00 Upcoming Season", "05 Onfield Performance", 
"03 Sponsorship", "05 Onfield Performance", "05 Onfield Performance", 
"03 Sponsorship", "03 Sponsorship", "02 Personal", "05 Onfield Performance", 
"05 Onfield Performance", "02 Personal", "09 Off-field Responsibilities", 
"01 Charities", "05 Onfield Performance", "05 Onfield Performance", 
"05 Onfield Performance", "03 Sponsorship", "00 Upcoming Season", 
"03 Sponsorship", "00 Upcoming Season", "03 Sponsorship", "03 Sponsorship", 
"02 Personal", "00 Upcoming Season", "03 Sponsorship", "00 Upcoming Season", 
"03 Sponsorship", "00 Upcoming Season", "03 Sponsorship", "00 Upcoming Season", 
"05 Onfield Performance", "05 Onfield Performance", "00 Upcoming Season", 
"02 Personal", "00 Upcoming Season", "00 Upcoming Season", "09 Off-field Responsibilities", 
"05 Onfield Performance", "02 Personal", "03 Sponsorship", "00 Upcoming Season", 
"00 Upcoming Season", "02 Personal", "02 Personal", "05 Onfield Performance", 
"05 Onfield Performance", "00 Upcoming Season", "00 Upcoming Season", 
"00 Upcoming Season", "02 Personal", "05 Onfield Performance", 
"02 Personal", "03 Sponsorship", "03 Sponsorship", "01 Charities", 
"02 Personal", "03 Sponsorship", "02 Personal", "03 Sponsorship", 
"05 Onfield Performance", "05 Onfield Performance", "06 Shoutout", 
"01 Charities", "05 Onfield Performance", "01 Charities", "01 Charities", 
"03 Sponsorship", "09 Off-field Responsibilities", "04 Pop Culture", 
"01 Charities", "01 Charities", "01 Charities", "02 Personal", 
"01 Charities", "03 Sponsorship", "03 Sponsorship", "06 Shoutout", 
"01 Charities", "09 Off-field Responsibilities", "01 Charities", 
"04 Pop Culture", "01 Charities", "01 Charities", "01 Charities", 
"02 Personal", "01 Charities", "03 Sponsorship", "03 Sponsorship", 
"01 Charities", "03 Sponsorship", "05 Onfield Performance", "05 Onfield Performance", 
"07 Politics", "03 Sponsorship", "02 Personal", "01 Charities", 
"03 Sponsorship", "01 Charities", "01 Charities", "03 Sponsorship", 
"01 Charities", "01 Charities", "05 Onfield Performance", "09 Off-field Responsibilities", 
"03 Sponsorship", "01 Charities", "09 Off-field Responsibilities", 
"02 Personal", "01 Charities", "01 Charities", "03 Sponsorship", 
"02 Personal", "01 Charities", "09 Off-field Responsibilities", 
"01 Charities", "02 Personal", "02 Personal", "11 Other", "06 Shoutout", 
"06 Shoutout", "06 Shoutout", "06 Shoutout", "06 Shoutout", "06 Shoutout", 
"06 Shoutout", "06 Shoutout", "09 Off-field Responsibilities", 
"01 Charities", "05 Onfield Performance", "06 Shoutout", "09 Off-field Responsibilities", 
"09 Off-field Responsibilities", "03 Sponsorship", "05 Onfield Performance", 
"09 Off-field Responsibilities", "09 Off-field Responsibilities", 
"06 Shoutout", "02 Personal", "07 Politics", "09 Off-field Responsibilities", 
"05 Onfield Performance", "05 Onfield Performance", "02 Personal", 
"05 Onfield Performance", "07 Politics", "06 Shoutout", "05 Onfield Performance", 
"09 Off-field Responsibilities", "09 Off-field Responsibilities", 
"10 Other Athletes", "05 Onfield Performance", "03 Sponsorship", 
"08 Throwback", "05 Onfield Performance", "02 Personal", "05 Onfield Performance", 
"00 Upcoming Season", "05 Onfield Performance", "03 Sponsorship", 
"03 Sponsorship", "05 Onfield Performance", "03 Sponsorship", 
"09 Off-field Responsibilities", "06 Shoutout", "05 Onfield Performance", 
"00 Upcoming Season", "03 Sponsorship", "03 Sponsorship", "09 Off-field Responsibilities", 
"05 Onfield Performance", "09 Off-field Responsibilities", "10 Other Athletes", 
"02 Personal", "02 Personal", "09 Off-field Responsibilities", 
"03 Sponsorship", "05 Onfield Performance", "09 Off-field Responsibilities", 
"03 Sponsorship", "00 Upcoming Season", "03 Sponsorship", "09 Off-field Responsibilities", 
"05 Onfield Performance", "05 Onfield Performance", "10 Other Athletes", 
"00 Upcoming Season", "02 Personal", "08 Throwback", "00 Upcoming Season", 
"00 Upcoming Season", "02 Personal", "02 Personal", "03 Sponsorship", 
"02 Personal", "02 Personal", "03 Sponsorship", "02 Personal", 
"02 Personal", "02 Personal", "07 Politics", "08 Throwback", 
"03 Sponsorship", "10 Other Athletes", "03 Sponsorship", "05 Onfield Performance", 
"03 Sponsorship", "11 Other", "11 Other", "03 Sponsorship", "03 Sponsorship", 
"02 Personal", "02 Personal", "05 Onfield Performance", "09 Off-field Responsibilities", 
"02 Personal", "09 Off-field Responsibilities", "05 Onfield Performance", 
"08 Throwback", "09 Off-field Responsibilities", "02 Personal", 
"09 Off-field Responsibilities", "11 Other", "02 Personal", "10 Other Athletes", 
"05 Onfield Performance", "02 Personal", "08 Throwback", "05 Onfield Performance", 
"05 Onfield Performance", "09 Off-field Responsibilities", "10 Other Athletes", 
"02 Personal", "11 Other", "05 Onfield Performance", "08 Throwback", 
"11 Other", "09 Off-field Responsibilities", "10 Other Athletes", 
"09 Off-field Responsibilities", "10 Other Athletes", "03 Sponsorship", 
"02 Personal", "09 Off-field Responsibilities", "09 Off-field Responsibilities", 
"05 Onfield Performance", "09 Off-field Responsibilities", "02 Personal", 
"06 Shoutout", "09 Off-field Responsibilities", "02 Personal", 
"09 Off-field Responsibilities", "10 Other Athletes", "10 Other Athletes", 
"09 Off-field Responsibilities", "06 Shoutout", "02 Personal", 
"10 Other Athletes", "10 Other Athletes", "02 Personal", "02 Personal", 
"10 Other Athletes", "09 Off-field Responsibilities", "10 Other Athletes", 
"09 Off-field Responsibilities", "06 Shoutout", "11 Other", "11 Other", 
"06 Shoutout", "06 Shoutout", "06 Shoutout", "06 Shoutout", "06 Shoutout", 
"10 Other Athletes", "04 Pop Culture", "02 Personal", "02 Personal", 
"02 Personal", "05 Onfield Performance", "07 Politics", "02 Personal", 
"10 Other Athletes", "02 Personal", "11 Other", "10 Other Athletes", 
"07 Politics", "09 Off-field Responsibilities", "02 Personal", 
"09 Off-field Responsibilities", "05 Onfield Performance", "02 Personal", 
"05 Onfield Performance", "03 Sponsorship", "02 Personal", "07 Politics", 
"05 Onfield Performance", "07 Politics", "07 Politics", "07 Politics", 
"05 Onfield Performance", "09 Off-field Responsibilities", "02 Personal", 
"11 Other", "03 Sponsorship", "05 Onfield Performance", "05 Onfield Performance", 
"03 Sponsorship", "03 Sponsorship", "07 Politics", "02 Personal", 
"10 Other Athletes", "09 Off-field Responsibilities", "03 Sponsorship", 
"09 Off-field Responsibilities", "09 Off-field Responsibilities", 
"02 Personal", "02 Personal", "07 Politics", "03 Sponsorship", 
"05 Onfield Performance", "09 Off-field Responsibilities", "03 Sponsorship", 
"03 Sponsorship", "09 Off-field Responsibilities", "05 Onfield Performance", 
"05 Onfield Performance", "07 Politics", "05 Onfield Performance", 
"10 Other Athletes", "05 Onfield Performance", "11 Other", "02 Personal", 
"05 Onfield Performance", "03 Sponsorship", "07 Politics", "07 Politics", 
"07 Politics", "07 Politics", "07 Politics", "09 Off-field Responsibilities", 
"10 Other Athletes", "06 Shoutout", "05 Onfield Performance", 
"10 Other Athletes", "10 Other Athletes", "03 Sponsorship", "10 Other Athletes", 
"05 Onfield Performance", "05 Onfield Performance", "02 Personal", 
"05 Onfield Performance", "07 Politics"), fb_Likes = c(147000L, 
162000L, 332000L, 439000L, 319000L, 167000L, 330000L, 298000L, 
278000L, 208000L, 154000L, 185000L, 231000L, 239000L, 488000L, 
155000L, 196000L, 478000L, 216000L, 141000L, 194000L, 202000L, 
274000L, 359000L, 158000L, 595000L, 182000L, 185000L, 80000L, 
135000L, 260000L, 272000L, 164000L, 271000L, 105000L, 158000L, 
204000L, 121000L, 135000L, 178000L, 63000L, 149000L, 119000L, 
147000L, 249000L, 284000L, 180000L, 593000L, 213000L, 225000L, 
241000L, 181000L, 208000L, 203000L, 296000L, 125000L, 435000L, 
328000L, 216000L, 252000L, 226000L, 231000L, 345000L, 307000L, 
338000L, 576000L, 289000L, 212000L, 312000L, 874000L, 386000L, 
96000L, 197000L, 556000L, 97000L, 930000L, 176000L, 1600000L, 
785000L, 579000L, 622000L, 1600000L, 1000000L, 697000L, 661000L, 
189000L, 1400000L, 627000L, 681000L, 985000L, 727000L, 1000000L, 
929000L, 978000L, 847000L, 1300000L, 854000L, 908000L, 1000000L, 
815000L, 148000L, 680000L, 916000L, 517000L, 161000L, 1400000L, 
974000L, 598000L, 1600000L, 798000L, 135000L, 1200000L, 1200000L, 
1400000L, 511000L, 935000L, 425000L, 686000L, 581000L, 716000L, 
1300000L, 828000L, 671000L, 848000L, 545000L, 633000L, 91000L, 
1100000L, 1400000L, 672000L, 1000000L, 1200000L, 736000L, 1000000L, 
683000L, 812000L, 1300000L, 241000L, 999000L, 953000L, 1900000L, 
1300000L, 100000L, 1500000L, 1300000L, 100000L, 706000L, 1500000L, 
1200000L, 2200000L, 138L, 151L, 3500L, 2700L, 12L, 5500L, 206L, 
1300L, 933L, 4000L, 1500L, 625L, 1700L, 2100L, 130L, 3500L, 1300L, 
1600L, 1750L, 3600L, 168L, 980L, 126L, 147L, 1100L, 1500L, 3500L, 
4300L, 1200L, 3700L, 2600L, 760L, 2700L, 2500L, 156L, 130L, 1700L, 
87L, 975L, 1200L, 2300L, 140L, 2300L, 1800L, 98L, 1900L, 2700L, 
1700L, 150L, 2000L, 1200L, 3700L, 156L, 2400L, 3700L, 155L, 1500L, 
2000L, 778L, 981L, 123L, 3700L, 985L, 2100L, 74L, 93L, 120L, 
660L, 177L, 134L, 169L, 1500L, 1300L, 1100L, 1000000L, 173798L, 
184350L, 349668L, 169722L, 370084L, 41196L, 227641L, 139077L, 
170818L, 195434L, 275576L, 23964L, 215125L, 222401L, 238528L, 
186610L, 242546L, 230264L, 160129L, 155294L, 104889L, 363315L, 
62592L, 258133L, 213028L, 42128L, 268633L, 54758L, 271158L, 340032L, 
636786L, 50978L, 324209L, 458008L, 61564L, 263577L, 260373L, 
255664L, 90504L, 79281L, 86542L, 247029L, 247392L, 273509L, 678358L, 
498855L, 219236L, 440383L, 58323L, 441537L, 222854L, 106647L, 
169164L, 74627L, 243347L, 576549L, 691629L, 564120L, 161433L, 
347161L, 243750L, 239125L, 177537L, 100315L, 449977L, 33364L, 
539864L, 147940L, 63055L, 162502L, 47826L, 455215L, 178912L, 
347571L, 110622L, 60700L, 13000L, 78400L, 15400L, 124000L, 68100L, 
36700L, 61400L, 34800L, 38900L, 86900L, 24200L, 16000L, 53900L, 
51600L, 58300L, 32700L, 40600L, 47600L, 200000L, 29900L, 71300L, 
102000L, 27000L, 26800L, 31800L, 81400L, 15200L, 38200L, 325000L, 
133000L, 121000L, 35300L, 93400L, 46100L, 60000L, 50600L, 34000L, 
94000L, 48000L, 98000L, 206000L, 47000L, 29000L, 18000L, 42000L, 
162000L, 49000L, 51000L, 31000L, 37000L, 161000L, 83000L, 29000L, 
105000L, 48000L, 27000L, 57000L, 48000L, 21000L, 57000L, 86000L, 
112000L, 126000L, 309000L, 65000L, 48000L, 76000L, 22000L, 59000L, 
23000L, 123000L, 55000L, 72000L, 51000L, 202525L, 29241L, 303359L, 
283098L, 395091L, 63690L, 553574L, 103153L, 129810L, 291100L, 
283324L, 75878L, 93428L, 55684L, 86660L, 342016L, 15746L, 199480L, 
11612L, 11336L, 17126L, 99117L, 140578L, 255422L, 8020L, 101428L, 
406858L, 82288L, 87831L, 48572L, 61207L, 446103L, 172178L, 153797L, 
23919L, 603707L, 158060L, 458647L, 405635L, 23537L, 146939L, 
177193L, 190605L, 10845L, 12847L, 303696L, 183960L, 608762L, 
57376L, 621922L, 285299L, 257097L, 114347L, 294125L, 157214L, 
52844L, 130187L, 10213L, 415479L, 126313L, 90319L, 87047L, 78808L, 
348451L, 272894L, 236654L, 325456L, 198106L, 459927L, 164522L, 
279294L, 340502L, 164667L, 125458L)), class = "data.frame", row.names = c(NA, 
-449L), .Names = c("Player", "Theme", "fb_Likes"))

1 个答案:

答案 0 :(得分:4)

尝试一下:

df %>% 
  group_by(Player, Theme) %>% summarise(Likes = mean(fb_Likes)) %>%
  ungroup() %>% #Change made here
  group_by(Player) %>% #and here
  mutate(ismax = ifelse(Likes == max(Likes), "Max", "NotMax")) %>% #and here
  ggplot(aes(x = Theme, y = Likes), color = "white") + 
  geom_bar(stat = "identity", aes(group = Player, fill = ismax)) + #and here
  scale_fill_manual(values = c('#888888', '#333333') ) +
  theme_tufte(base_size = 12, 
              base_family = "sans", 
              ticks = TRUE) + 
  coord_flip() +   
  theme(legend.position = "none", panel.background = element_blank()) +
  facet_grid(Player ~., space = "free")

enter image description here

我在数据中添加了一列ismax,以查找每个Theme最多的Player。然后,您对该列进行fill审美。有可能在ggplot的调用中完成所有这些操作,但我在调用之前完成了这一操作。