文章目录
映射函数aes()
在默认情况aes(wpg,mt)下用映射函数更改图层属性
操作 | 层图形属性 | 结果 |
---|---|---|
添加 | aes(colour=cyl) | aes(wpg,mt,colour=cyl) |
修改 | ase(y=disp) | aes(wpg,disp) |
删除 | ase(y=NULL) | aes(wpg) |
library(ggplot2)
library(ggpubr)
p<-ggplot(mtcars,aes(x=mpg,y=wt))
a1<-p+geom_point(colour="darkblue")
a2<-p+geom_point(aes(colour="darkblue"))
a<-ggarrange(a1,a2,ncol=2)
a
在qplot里可以通过I()函数实现映射,如colour=I(“darkblue”)
不同图层上的不同分组:
p<-ggplot(Oxboys, aes(age, height, group = Subject)) +geom_line()
a3<-p+geom_smooth(aes(group=Subject),method = "lm",se=F)
a4<-p+geom_smooth(aes(group=1