R ggplot2 改变颜色

p<-ggplot(iris,aes(Petal.Length,Petal.Width,color=Species))+geom_point()
cols=c("red","green","blue")
scale_colour_manual和scale_fill_manual用法相同
更改颜色和legend lables

p + scale_colour_manual(values = cols, breaks = c("4", "6", "8"), labels = c("four", "six", "eight"))
更改背景
p + scale_colour_manual(values = cols, breaks = c("4", "6", "8"), labels = c("four", "six", "eight"))+theme_bw()+theme(legend.title=element_blank(),panel.grid =element_blank(), panel.grid.major=element_blank())
原文地址:https://www.cnblogs.com/yangyongzhi/p/6523282.html