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