[英]R: change colors across bars in stacked bar chart
Using base graphics, I got a barchart like this one 使用基本图形,我得到了一个像这样的条形图
a <- c(1,2,3); b <- c(1,1,1)
barplot(rbind(a,b), col=c("red","gray"))
with each bar grey at the top and red at the bottom. 每个栏的顶部为灰色,底部为红色。 However, I would like each bar to change the color at the bottom and keep the grey at the top.
但是,我希望每个栏在底部更改颜色,在顶部保留灰色。
cols <- c(rbind(c("red","green","blue"),"gray"))
barplot(rbind(a,b), col=cols)
did not do the trick. 没有做到这一点。 Is there any other way?
还有其他办法吗?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.