||
#参考https://blog.csdn.net/zhouhucheng00/article/details/106413401
#加载所需的包并设置主题样式
library(ggplot2)
library(ggpubr)
library(ggpmisc)
theme_set(ggpubr::theme_pubr()+
theme(legend.position = "top"))
#加载目标数据
df<-read.csv("richness.csv", header = T)
#数据样式
#使用 ggscatter() 也可以轻松绘制散点图,并可以使用 stat_cor() 自动添加相关系数和显著性水平(P值)。
p<-ggscatter(df, x = "richness", y = "plant",
add = "reg.line", conf.int = TRUE,
add.params = list(color = "blue", fill = "lightgray")
)
p + stat_cor(method = "spearman", label.x = 0.07, label.y = 0.7)
p + stat_cor(p.accuracy = 0.001, r.accuracy = 0.01)
p<-p + stat_cor(p.accuracy = 0.001, r.accuracy = 0.01)
p<-p + labs( x = "Microbial community richness", y = "Plant growth promotion
by microbial communities (%)")
#图片保存
ggsave(p,filename = "richness.jpg",width = 4,height =4)
#图片展示
Archiver|手机版|科学网 ( 京ICP备07017567号-12 )
GMT+8, 2024-9-1 11:02
Powered by ScienceNet.cn
Copyright © 2007- 中国科学报社