❝https://www.nature.com/articles/s41467-024-45957-x ❞
library(tidyverse)
library(ggtext)
df <- read_tsv("data.xls") %>% rownames_to_column(var="id") %>%
pivot_longer(-id)
df$name <- factor(df$name,levels =df$name %>% unique())
p1 <- df %>% separate(col=name,into="type", sep="_",remove = F)
p1 %>% ggplot(aes(name,value,fill=type))+
stat_boxplot(geom="errorbar",width=0.2)+
geom_boxplot(outlier.shape = NA,key_glyph="rect")+
stat_summary(fun=mean,geom="point",col="white",shape=15,show.legend = F)+
geom_hline(yintercept = 0,linetype="3313",color="black",size=0.5)+
labs(y="(gC m<sup>-2</sup> ppm<sup>-1</sup>)")+
scale_y_continuous(limits = c(-10,10),position = "right")+
scale_fill_manual(values=c("#DD8D29","#74A089","#899DA4"))+
theme_test()+
theme(axis.text.x=element_blank(),
axis.title.x = element_blank(),
axis.text.y.right=element_text(color="black",size=11,margin = margin(l=8,"in")),
axis.title.y.right=element_markdown(size=10,color="black",angle = 90,face = "bold"),
axis.ticks.x = element_blank(),
axis.ticks.length.y.right = unit(-0.2,"cm"),
plot.margin = unit(c(0.8,0.8,0.8,0.8),unit="cm"),
legend.key.height = unit(0.4,"cm"),
legend.key.width = unit(1,"cm"),
legend.title=element_blank(),
legend.text=element_markdown(size=10,vjust=0.5,hjust=0.5),
legend.spacing.x = unit(0.03,"in"),
legend.direction = "horizontal",
legend.position = c(0.238,-0.03))