更改ggplot中的默认颜色geo_bar

时间:2018-04-09 17:48:07

标签: r ggplot2

enter image description here我想更改geom_bars的默认填充颜色,但收到错误消息。我已经将fill函数设置为我的变量(Accident_severity_combined),以显示条形图中严重性的分布,但是想要更改出现的默认颜色..但是我得到错误消息如下:非数字参数到二元运算符

省略函数scale_fill_manual时,图表加载正常。 ?

 p<- ggplot(uk, aes(x = Road_Type)) + 
 geom_bar(aes(y = (..count..)/sum(..count..), fill = 
 Accident_Severity_combined)) +  
 scale_fill_manual(values = ("Serious" = "blue","Slight" = "red")) + 
 geom_text(aes(y = ((..count..)/sum(..count..)), label = 
 scales::percent((..count..)/sum(..count..))), stat = "count", vjust = -0.25) +
 scale_y_continuous(labels = percent) + 
 labs(title = "Accident Severity by Road Type", y = "Percent", x = "Road Type")

0 个答案:

没有答案
相关问题