Closed
Description
Hi!
I am using ggplot2 quite often, and I ran into a problem concerning the ordering of colors. So I am setting the breaks and the color values in scale_fill_manual()
, and I would expect that the first color "black" would be assigned to the first break ('small') and so on. This seems to happen when the grouping variable is data type = character. I suppose you transform the variable into a factor internally, or something like that.
Is this the intended behaviour, because for me this is really confusing?!
test <- data.frame(a=as.character(gl(n = 4, length = 8, k = 2, labels = letters[1:4])),
b=as.character(gl(n = 2, length = 8, k = 1, labels = c("small", "big"))),
values = sample(10:300, 8))
pl1 <- ggplot(test, aes(x=a, y=values, fill=b))
pl1 + geom_bar(stat="identity", position="dodge") +
scale_fill_manual("test", breaks=c("small", "big") , values = c("black","tomato2"))
Thank you!!
Manuel