library(ggplot2)
df <- data.frame(trt=c("TAVERN","Long Term Care","Grocery Store","Restaurant"),
outcome=c("a","b","c","d"))
ggplot(df,aes(trt, outcome)) +
geom_col() +
geom_point(colour = 'red') +
ggtitle("Failing rate in different facility types") +
labs(x="Facility type",y="Failing rate") +
theme(panel.background = element_blank()) +
scale_color_manual(values = c("purple","green", "red", "orange"))
我尝试手动更改ggplot中的颜色。
但是我没有这样做。真的很困惑。
问题。如何依次设置ggplot()
函数的参数
改变条形的颜色?
答案 0 :(得分:1)
我假设您想更改条形的颜色。然后,您需要指定fill
的{{1}}选项。
geom_col
或者,您可以设置library(ggplot2)
df <- data.frame(trt=c("TAVERN","Long Term Care","Grocery Store","Restaurant"),
outcome=c("a","b","c","d"))
ggplot(df,aes(trt, outcome)) +
geom_col(fill=c("purple","green", "red", "orange")) +
geom_point(colour = 'red') +
ggtitle("Failing rate in different facility types") +
labs(x="Facility type", y="Failing rate") +
theme(panel.background = element_blank())
美观。请注意,fill
用于内部。 fill
用于边界。
colour