##############################################soil N figure 8 data <- read.csv("soil N.csv") df <- data %>% filter(year == 2020) #2020——NH4_two layer figure 8A p1 <- ggplot(data=df, aes(x=factor(Date, level=c('2020/8/6', '2020/8/27', '2020/10/3')),y=nh4_1, fill=factor(treatment,level=c('N0', 'N20', 'N60', 'N120', 'N180')))) + facet_grid( ~ layer) + geom_bar(position = "dodge", stat="identity",colour = "black",size=0.3)+ geom_errorbar(aes(x = Date, y = nh4_1, ymin = nh4_1 - nh4_1_Error, ymax = nh4_1 + nh4_1_Error), width = 0.3,size=0.3,position=position_dodge(.9)) + xlab(expression(paste(Date)))+ labs(y=expression(~Soil~NH[4]^{"+"}-N~concentration~(mg~kg^{-1})))+ mytheme2+ theme(legend.position = c(0.15, 0.88), legend.text = element_text(size = 8, family = "serif"), legend.title = element_text( size = 7), legend.key.size = unit(0.3, 'cm'), legend.background = element_rect(fill = 'transparent'))+ scale_y_continuous(expand = c(0,0),limits = c(0,8)) + labs(fill=' ')+ geom_text(label = c("Aa", "Ba", "ABa","Aa", "Ba", "Acd", "ABab", "Bd", "Abc", "Aa", "Aa", "Aa", "Aa", "Aa", "ABa", "b", "ab", "ab","a", "ab", "a", "a", "a", "a", "a", "b", "b", "b", "b", "a"), family="serif", aes(y = nh4_1 + nh4_1_Error, x = Date), hjust = 0.45,vjust= -0.4, size = 3, position = position_dodge(width = 0.9), stat="identity")+ scale_fill_manual( values = c("#00AFBB", "#E7B800", "#FC4E07","cornflowerblue","violet"),name = NULL)+ theme( axis.title.y = element_text(vjust = 3,margin = margin(t =0, r = 0, b = 0, l = 0)), axis.title.x = element_text(vjust = -1,margin = margin(t =0, r = 0, b = 0, l = 0)))+ theme(plot.margin = unit(c(1,1,0.5,1), "cm"))+ # ("left", "top", "bottom", "right")+ guides (fill=guide_legend (nrow=1)) p1 #2020——NO3_two layer figure 8B p2 <- ggplot(data=df, aes(x=factor(Date, level=c('2020/8/6', '2020/8/27', '2020/10/3')),y=no3_1, fill=factor(treatment,level=c('N0', 'N20', 'N60', 'N120', 'N180')))) + facet_grid( ~ layer) + geom_bar(position = "dodge", stat="identity",colour = "black",size=0.3)+ geom_errorbar(aes(x = Date, y = no3_1, ymin = no3_1 - no3_1_Error, ymax = no3_1 + no3_1_Error), width = 0.3,size=0.3,position=position_dodge(.9)) + xlab(expression(paste(Date)))+ labs(y=expression(Soil~NO[3]^{"-"}-N~concentration~(mg~kg^{-1})))+ mytheme2+ theme(legend.position = c(0.06,0.77), legend.text = element_text(size = 8, family = "serif"), legend.title = element_text( size = 7), legend.key.size = unit(0.3, 'cm'), legend.background = element_rect(fill = 'transparent'))+ scale_y_continuous(expand = c(0,0),limits = c(0,80),breaks=seq(0,80,20)) + geom_text(label = c("b", "ab", "ab","a", "ab", "b", "b", "b", "b", "a", "b", "ab", "ab", "ab", "a", "b", "b", "b","a", "a", "b", "b", "ab", "ab", "a", "a", "a", "a", "a", "a"), family="serif", aes(y = no3_1 + no3_1_Error, x = Date), hjust = 0.45,vjust= -0.4, size = 3, position = position_dodge(width = 0.9), stat="identity")+ scale_fill_manual( values = c("#00AFBB", "#E7B800", "#FC4E07","cornflowerblue","violet"),name = NULL)+ theme( axis.title.y = element_text(vjust = 3,margin = margin(t =0, r = 0, b = 0, l = 0)), axis.title.x = element_text(vjust = -1,margin = margin(t =0, r = 0, b = 0, l = 0)))+ theme(plot.margin = unit(c(1,1,0.5,1), "cm")) # ("left", "top", "bottom", "right") p2 df <- data %>% filter(year == 2021) data$cut1 = factor(data$cut,levels=c('First regrowth','Second regrowth','Third regrowth')) #2021——NH4_1two layer figure 8C p3 <- ggplot(data=df, aes(x=factor(Date, level=c('2021/5/26', '2021/6/3', '2021/6/15', '2021/7/16','2021/7/30','2021/8/7','2021/9/24')),y=nh4_1, fill=factor(treatment,level=c('N0', 'N20', 'N60', 'N120', 'N180')))) + facet_grid(layer~cut1, scales="free", space="free_x") + geom_bar(position = "dodge", stat="identity",colour = "black",size=0.3)+ geom_errorbar(aes(x = Date, y = nh4_1, ymin = nh4_1 - nh4_1_Error, ymax = nh4_1 + nh4_1_Error), width = 0.3,size=0.3,position=position_dodge(.9)) + xlab(expression(paste(Date)))+ labs(y=expression(~Soil~NH[4]^{"+"}-N~concentration~(mg~kg^{-1})))+ mytheme2+ theme(legend.position = c(0.15, 0.95), legend.text = element_text(size = 8, family = "serif"), legend.title = element_text( size = 7), legend.key.size = unit(0.3, 'cm'), legend.background = element_rect(fill = 'transparent'))+ scale_y_continuous(expand = c(0,0),limits = c(0,8)) + labs(fill=' ')+ geom_text(label = c("Ba", "ABa", "ABa","ABa", "ABa", "ABab", "ABab", "Aa", "ABb", "ABb", "Aa", "Aa", "Aa", "ABab", "ABb", "Aa", "ABab", "ABab","Aa", "BCb", "ABa", "Ba", "Ba","BCa", "Aa", "ABa", "ABab", "Bb", "ABCb", "ABab", "Ca", "Ca", "Ca","Ca", "Ca", "ABa", "ABa", "ABa","Aa", "ABa", "ABb", "Aab", "Aab", "Ab", "Aa", "ABba", "Aa", "Aa","Aa", "ABa", "Aa", "ABa", "ABa","Aa", "Ba", "Bab", "ABab", "Bb", "Aab", "Aa", "Ba", "ABa", "ABa","Aa", "Ba", "Ca", "Ba", "Ca","Ba", "Ca"), family="serif", aes(y = nh4_1 + nh4_1_Error, x = Date), hjust = 0.45,vjust= -0.4, size = 3, position = position_dodge(width = 0.9), stat="identity")+ theme(panel.spacing.y = unit(1, "lines"))+ scale_fill_manual( values = c("#00AFBB", "#E7B800", "#FC4E07","cornflowerblue","violet"),name = NULL)+ theme( axis.title.y = element_text(vjust = 3,margin = margin(t =0, r = 0, b = 0, l = 0)), axis.title.x = element_text(vjust = -1,margin = margin(t =0, r = 0, b = 0, l = 0)))+ theme(plot.margin = unit(c(1,1,0.5,1), "cm"))+ # ("left", "top", "bottom", "right") guides (fill=guide_legend (nrow=1)) p3 ##2021—NO3_1two layer figure 8D p4 <- ggplot(data=df, aes(x=factor(Date, level=c('2021/5/26', '2021/6/3', '2021/6/15', '2021/7/16','2021/7/30','2021/8/7','2021/9/24')),y=no3_1, fill=factor(treatment,level=c('N0', 'N20', 'N60', 'N120', 'N180')))) + facet_grid(layer~cut1, scales="free", space="free_x") + geom_bar(position = "dodge", stat="identity",colour = "black",size=0.3)+ geom_errorbar(aes(x = Date, y = no3_1, ymin = no3_1 - no3_1_Error, ymax = no3_1 + no3_1_Error), width = 0.3,size=0.3,position=position_dodge(.9)) + xlab(expression(paste(Date)))+ labs(y=expression(Soil~NO[3]^{"-"}-N~concentration~(mg~kg^{-1})))+ mytheme2+ theme(legend.position = c(0.05,0.86), legend.text = element_text(size = 8, family = "serif"), legend.title = element_text( size = 7), legend.key.size = unit(0.3, 'cm'), legend.background = element_rect(fill = 'transparent'))+ scale_y_continuous(expand = c(0,0),limits = c(0,80),breaks=seq(0,80,20)) + labs(fill=' ')+ geom_text(label = c("Aa", "Aa", "Aa","ABa", "ABa", "Ab", "Ab", "Ab", "Aab", "Aa", "Ab", "Ab", "Ab", "ABb", "ABa", "Aa", "Aa", "Aa","ABa", "ABa", "Ab", "Aab", "Bab", "Bab", "Ba", "Aa", "Aa", "Ba","Ba", "Ba", "Aa", "Aa", "Ba","Ba", "Ba", "b", "ab", "ab","a", "a", "a", "a", "a", "a", "a", "b", "b", "b", "b", "a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "b", "b", "a", "a", "ab", "a", "a", "a", "a", "a"), family="serif", aes(y = no3_1 + no3_1_Error, x = Date), hjust = 0.45,vjust= -0.4, size = 3, position = position_dodge(width = 0.9), stat="identity")+ theme(panel.spacing.y = unit(1, "lines"))+ scale_fill_manual( values = c("#00AFBB", "#E7B800", "#FC4E07","cornflowerblue","violet"),name = NULL)+ theme( axis.title.y = element_text(vjust = 3,margin = margin(t =0, r = 0, b = 0, l = 0)), axis.title.x = element_text(vjust = -1,margin = margin(t =0, r = 0, b = 0, l = 0)))+ theme(plot.margin = unit(c(1,1,0.5,1), "cm")) # ("left", "top", "bottom", "right") p4 plot_all <- cowplot::plot_grid(p1, p2,p3,p4, labels = "AUTO",label_fontfamily="serif",nrow = 4,rel_heights = c (1.5, 1.5,2,2)) plot_all ggsave("paper_soil_c.png", plot=plot_all, height=35, width=25, units="cm", dpi=600)