geom_bar define border color with different fill colors

93.3k Views Asked by At

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")

How do I correctly use geom_bar so that it gives me the correct black border?

1

There are 1 best solutions below

1
On BEST ANSWER

You have to put colour outside aes:

ggplot(test) + geom_bar(aes(x=a, y=b, fill=c), colour="black", stat="identity")

enter image description here