对AIC分面作图

载入数据

AIC_huizong <- read.csv("D:/R/Spatial_Compete/results/che_reped/res/AIC_huizong.csv")
str(AIC_huizong)
## 'data.frame':    7 obs. of  11 variables:
##  $ pr     : Factor w/ 2 levels "npr","pr": 1 1 1 2 2 2 2
##  $ model  : Factor w/ 4 levels "B","B-AR","B-Spl",..: 3 2 4 1 3 2 4
##  $ h05    : num  343.65 588.73 576.1 -2.85 345.75 ...
##  $ d05    : num  154.5 179.1 177.2 16.6 173.7 ...
##  $ v05    : num  177.9 211.7 207 11.6 193.3 ...
##  $ h14    : num  525.13 577.51 612.91 -5.46 524.46 ...
##  $ d14    : num  108.54 115.68 115.29 2.81 112.35 ...
##  $ v14    : num  208.49 203.59 218.89 1.11 211.09 ...
##  $ alfacel: num  -4.2 NA NA -112.2 -114.2 ...
##  $ lignin : num  21.4 16.16 22.55 -16.66 1.58 ...
##  $ holocel: num  -2.03 NA NA -145.25 -146.49 ...
# reshape
library(reshape2)

AIC_reshape <- melt(AIC_huizong,ID=names(AIC_huizong))
## Using pr, model as id variables
names(AIC_reshape)[3:4] <- c("trait","AIC")
AIC_reshape$trait <- factor(AIC_reshape$trait)

library(ggplot2)
p <- ggplot(AIC_reshape, aes(model,AIC)) + geom_point(aes(colour=pr))+geom_hline(yintercept=0,linetype="dashed",colour="grey",size=.1)
p <- p+facet_grid(.~trait)+facet_wrap(~trait,nrow = 3)

p+theme_bw()+theme(axis.text.x = element_text(angle = 60,hjust = 1.1,vjust = 1), plot.margin=unit(x=c(.2,.2,.2,.2),units = "cm"))
## Warning: Removed 8 rows containing missing values (geom_point).

# savename.pdf<-paste0(filename,".pdf")
# ggsave("AIC.pdf",width=5,height = 5,family = "serif")
# ggsave("AIC.wmf",width=5,height = 5,units = "in",family = "serif")