[英]change color in ggplot bar chart
如果您沒有特定的 colors,請檢查RColorBrewer
package。 它有許多組 colors 對色盲觀眾來說是安全的。
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
如果你想引起對一個欄的注意,你可以像這樣選擇特定的 colors
# 7 gray, then 1 red, then 2 gray
geom_col(fill = c(rep("gray", 7), "red", rep("gray", 2))) +
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.