我正在使用解决方法从 ggplot 图例中删除对角线:https ://groups.google.com/forum/?fromgroups=#!topic/ggplot2/vJnF9_HBqx4
使用以下数据,如何更改组的颜色?
# Create data #
a<-as.data.frame(c(1,1,1,2,2))
b<-as.data.frame(c("A","A","B","B","A"))
c<-as.data.frame(c(20,20,60,50,50))
a<-cbind(a,b,c)
colnames(a)<-c("X","Gp","Y")
# Plot #
ggplot(a, aes(x=X, y=Y,fill=Gp)) +
geom_bar(stat = "identity", aes(colour = "black")) +
scale_color_identity() +
theme(legend.key = element_rect(colour = "black", size = 1))
我尝试更改以下元素:
scale_color_identity(values=c("red","yellow"))
geom_bar(stat = "identity", aes(colour = c("red","yellow")))
geom_bar(stat = "identity", aes(colour = "black"), fill=c("red","yellow"))
但每个都会产生一个错误。