0

I am still new to r and was hoping for help on one of my plots. I am trying to add some color to this chart was looking for help doing so.my plot I believe the image should be included and any tips would be helpful. I'm not looking for anything specific but any advice for how to color the bars or outline them, or even color the background. Thanks for any help!

CODE:

 WorldCupMatches %>%
   filter(Year == "2014", Home.Team.Name %in% top10teams_in_order) %>%
   ggplot(aes(x = Home.Team.Name, y = Home.Team.Goals)) +
   geom_col()
  • Does this question help: https://stackoverflow.com/questions/50380819/create-barplots-in-ggplot2-filled-with-flags-or-images – Peter Apr 21 '21 at 20:00

1 Answers1

0

If you do not have specific colors in mind check the RColorBrewer package. It has many sets of colors that are safe for a color blind audience.

library(RColorBrewer)

 WorldCupMatches %>%
   filter(Year == "2014", Home.Team.Name %in% top10teams_in_order) %>%
   ggplot(aes(x = Home.Team.Name, y = Home.Team.Goals)) +
   geom_col(fill = brewer.pal(10,"Set3")) + # 10 colors one for each bar
   theme_bw() + # set general look
   theme(panel.grid.major.x=element_blank()) # remove horizontal gridlines

If you want to draw attention to one bar you can choose specific colors like this

# 7 gray, then 1 red, then 2 gray
geom_col(fill = c(rep("gray", 7), "red", rep("gray", 2))) +  
itsMeInMiami
  • 2,324
  • 1
  • 13
  • 34