library(tidyverse)
library(lme4)
library(emmeans)
library(multcomp)
# set theme for ggplot
theme_set(theme_bw())
theme_myBW <- theme(axis.title.x = element_text(size = 10, color = "black"),
axis.title.y = element_text(angle = 90, vjust = 1.5, size = 10, color = "black"),
axis.text.x = element_text(size = 10, color = "black"),
axis.text.y = element_text(size = 10, color = "black"),
axis.ticks =element_line(colour="black"),
strip.text.x = element_text(size = 10, color = "black"),
strip.background = element_blank(),
panel.border =element_rect(colour="black", fill=NA),
panel.grid.major = element_blank(),
panel.grid.minor = element_blank(),
plot.title = element_text(size = 12, hjust=0.5),
#legend.position=c(0.0,1.0),
#legend.justification=c(0,1),
legend.text = element_text(size = 10),
legend.text.align=0,
legend.title = element_text(size = 10),
legend.key = element_rect(colour="white", fill = "white"),
legend.key.size = unit(5, "mm"),
legend.background = element_blank())
# set vector with colors and label
COL <- c("Fallow" = "slategray", "Mustard" = "red3" , "Mix4" = "orchid3", "Mix12"= "orange4")
SHP <- c("Fallow"=21,"Mustard"=22,"Mix4"=23, "Mix12"=24)
# generate data frame with original data
data <- read.csv2("data.csv")
data$NEE <- as.numeric(sub('.', '', data$NEE, fixed = TRUE))
lm_NEE <- lmer(NEE ~ cc_variant + (1|Date), data=data)
df_NEE <- cld(emmeans(lm_NEE, specs ="cc_variant"), Letters=letters, sort=FALSE)
# Plot for BFS
fig1 <- ggplot(data, aes(x= cc_variant, y=NEE, fill= cc_variant))+
geom_boxplot()+
scale_fill_manual(values = COL, guide=FALSE)+
geom_text(data= df_NEE ,aes(y=-600,x=cc_variant, label=.group))+
labs(x="Catch crop variant", y=expression("NEE (mg CO"[2]~"- C"~m^{-2}~h^{-1}~")"), fill="")+
theme_myBW
#ggsave("Fig1.png", width = 84, height = 70, units = "mm", dpi = 600)
fig1