R 添加均值曲线
数据情况
计算均值
a.mean=aggregate(Value ~ Group, data = a, FUN = “mean”)
绘图
library(ggplot2)
library(ggpubr)
a=read.table("C:\\Users\\XXX\\Desktop\\result.finnal.xls.plot",head=T)
a.mean=aggregate(Value ~ Group, data = a, FUN = "mean")
p<-ggplot(a, aes(x=Group, y=Value)) +geom_point(size=2,shape=21,color="gray40")+theme_classic()+ scale_x_continuous(limits=c(2,16),breaks=seq(2,16,1)) +xlab("Number of genomes")+ylab("Number of gene families")
layer2<-geom_xspline(aes(x=Group, y=Value), a.mean, color="gray30",size=1.5,linetype="dashed",position = "identity",inherit.aes = FALSE)
p+ t