加载包
library(ggplot2)
library(readxl)
读取数据
data = read_excel("base_count.xlsx",sheet = 1)
表格抬头,使用Family作为X轴,AT%作为Y轴,%在R里面容易引起歧义识别不了抬头所以我去掉了。

基础
p1<-ggplot(data,aes(Family,AT,fill=Family))+geom_boxplot()

添加扰动点,离群点并设置颜色
p1<-ggplot(data,aes(Family,AT,fill=Family))+geom_boxplot()+
geom_boxplot(width=0.5,outlier.color = "red",outlier.shape = 2,outlier.size = 3)+
geom_jitter(shape=16, position=position_jitter(0.2),aes(colour = Subfamily))

p1<-ggplot(data,aes(Superfamily,AT,fill=Superfamily))+
geom_boxplot()+geom_boxplot(width=0.5,outlier.color = "red",
outlier.shape = 2,outlier.size = 3)+
geom_jitter(position=position_jitter(0.2),size = 0.5,aes(colour = Family))
+ coord_flip()
网友评论