library("ggsci")
library(ade4)
col <- c("mediumpurple3","lightblue","darkgreen")
tab.dist<-vegdist(mtcars,method='euclidean')
pcoa<- dudi.pco(tab.dist, scan = FALSE,nf=3)
pcoa_eig <- (pcoaeig)
sample_site <- data.frame({pcoanames <- rownames(sample_site)
names(sample_site)[1:2] <- c('PCoA1', 'PCoA2')
sample_sitegear)
sample_sitempg
t1<-sample_site
p1<-ggplot(t1,aes(PCoA1,PCoA2))+
geom_point(shape=21,aes(fill=groups),size=3)+
theme_test()+
xlab("")+ylab(paste('PCoA2(', round(100 * pcoa_eig[2], 2), '%)',sep = ""))+
theme(axis.text.x = element_blank())+scale_fill_manual(values = col)
p2<-ggplot(t1,aes(x=groups,y=PCoA1))+stat_boxplot(geom = "errorbar",size=.3)+
geom_boxplot(aes(fill=groups),outlier.fill = "white",outlier.color = "grey",outlier.shape = 21,size=.3)+
theme_void()+
theme(legend.position = "none")+scale_fill_manual(values=col)+coord_flip()
p3<-ggplot(t1,aes(PCoA1,mpg))+
geom_point(shape=21,fill="grey",alpha=.8)+
xlab(paste('PCoA1(', round(100 * pcoa_eig[1], 2), '%)',sep = ""))+
theme_classic()+
geom_smooth(method = "lm",se = F,color="black")+
annotate(geom = "text",label="R^2==0.860",x=200,y=30,parse=T)
p4<-p2/p1/p3+plot_layout(nrow=3,guides = "collect",heights = c(1,6,3))
ggsave(p4,filename = "changefont.pdf",device = cairo_pdf,family="DengXian Light",width=5,height = 5)