admin管理员组文章数量:1122832
I created a win/loss barchart with the y variable, wnls, coded -1 for loss and 1 for win. Then the bars were filled with red/loss and win/green. The code I used is below:
plot1<-ggplot(data=puck3 %>%
mutate(win_loss = ifelse(wnls < 0, "loss", "win")),
aes(x=GP, y=wnls, fill = win_loss)) +
geom_bar(stat="identity", width=0.5)+
scale_fill_manual(values = c("red", "green")) +
geom_col() +
ylim(-5,5)
I now want to expand the data set to include draws as well with loss/draw/win coded -1/0/1. Then the fill colors would be red/yellow/green. How do I alter the code above to do a three-color fill? Thanks for the help.
本文标签: ggplot2How to do a three color fill in R barchartStack Overflow
版权声明:本文标题:ggplot2 - How to do a three color fill in R barchart? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736301171a1931086.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论