<=element_text(angle=15,hjust =1,colour="black",family="Times",size=16), #设置x轴刻度标签的字体显⽰倾斜⾓度为15度,并向下调整1(hjust =1),字体簇为Times⼤⼩为16
>>>>>>>>>>##计算各个模型属性之间的差值
model1_model2 <- model1.attribute - model2.attribute
model1_model3 <- model1.attribute - model3.attribute
model1_model4 <- model1.attribute - model4.attribute
model1_model5 <- model1.attribute - model5.attribute
model2_model3 <- model2.attribute - model3.attribute
model2_model4 <- model2.attribute - model4.attribute
model2_model5 <- model2.attribute - model5.attribute
model3_model4 <- model3.attribute - model4.attribute
model3_model5 <- model3.attribute - model5.attribute
血小板减少会有什么后果model4_model5 <- model4.attribute - model5.attribute
#⽣成数据框
da<- data.frame(model1_model2,model1_model3,model1_model4,model1_model5,
model2_model3,model2_model4,model2_model5,
model3_model4,model3_model5,
七律model4_model5)
names(da)<-c("Model1 vs. Model2","Model1 vs. Model3","Model1 vs. Model4","Model1 vs. Model5",
"Model2 vs. Model3","Model2 vs. Model4","Model2 vs. Model5",
"Model3 vs. Model4","Model3 vs. Model5",
"Model4 vs. Model5")
#计算每两两模型之间差值的25%分位数,中位数,75%分位数
da_quantile <-apply(da,2,function(x)quantile(x,c(0.25,0.5,0.75)))
Data <- data.frame(names(da),da_quantile[1,],da_quantile[2,],da_quantile[3,])
names(Data)<-c("group_diff","down_diff","median_diff","up_diff")
>>>>>>>>>>##绘制模型之间的属性值的差异对⽐图
P2<-ggplot(Data,aes(x=group_diff,y=median_diff))+
geom_errorbar(aes(x=group_diff, ymin=down_diff , ymax=up_diff), width=0.3, colour="black", alpha=1, size=1.3)+ #使⽤绘制误差条图的⽅法绘制模型间差值的25%分位数,中位数,75%分位数
geom_point(size =4)+ #设置点的⼤⼩(对应模型间差值的中位数)
theme(axis.ticks.y =element_blank())+ #去除y轴的刻度线
geom_vline(xintercept =0.4,group=1)+geom_hline(yintercept =0,linetype=2,size=0.8)+ #绘制x=0和y=0直线
theme(
panel.background =element_rect(fill ="transparent",colour =NA), #背景⾊置为⽩⾊小新图片
<=element_text(size=12,face="bold"), #设置x轴的刻度字体⼤⼩九宫格数字
axis.title.x=element_text(size=12,face="bold"), #设置x轴的标题字体⼤⼩
<=element_text(size=12,face="bold"))+ #设置Y轴的刻度字体⼤⼩
coord_flip()+ #坐标轴旋转
xlab("")+ylab("Differences in asssment indicators between relevant pairs") #设置x轴,y轴的标签
P2
jpeg(file ="results_Value_3.jpg",width =2000,height =1500,units ="px",res =300) #结果保存
print(P2)
dev.off()
效果图如下:
图⼀ 使⽤R语⾔⾃带的boxplot()函数绘制的效果
图⼆ 使⽤ggplot2包绘制的效果
图三 不同模型间属性评估指标的差异对⽐图。其中,实⼼点表⽰相应模型之间的属性差值值的中位数,左边胡须表⽰下四分位数,右边胡须表⽰上四分位数。
由于使⽤ggpolt2包绘制的箱线图的胡须末端没有短横线,因此我也尝试了使⽤R语⾔⾃带的boxplot()函数绘制箱线图,效果图如图1所⽰。如果你知道如何使⽤ggplot2包绘制箱形图为胡须末端添加短横线,欢迎评论!