geom_bar用不同的填充颜色定义边框颜色 [英] geom_bar define border color with different fill colors
本文介绍了geom_bar用不同的填充颜色定义边框颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想用geom_bar
绘制条形图,我想要用黑色边框包围的独特填充颜色.但是,指令color="black"
并没有被解释为黑色",而是出现了红色边框.
I want to draw a bar plot with geom_bar
where I want unique fill colors surrounded by a black border. However the instruction color="black"
is not interpreted as "black" as I want it to be and I get red borders.
library(ggplot2)
test=as.data.frame(cbind(a=c(1,1,2,3), b=1:4, c=as.character(1:4)))
ggplot(test) + geom_bar(aes(x=a, y=b, fill=c, colour="black"), stat="identity")
如何正确使用geom_bar
,以便为我提供正确的黑色边框?
How do I correctly use geom_bar
so that it gives me the correct black border?
推荐答案
您必须将colour
放在aes
之外:
ggplot(test) + geom_bar(aes(x=a, y=b, fill=c), colour="black", stat="identity")
这篇关于geom_bar用不同的填充颜色定义边框颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文