R Markdown

library(readxl)
ICP_MS_ZZH_CFY_PS_H_PP_S_PP_updated <- read_excel("D:/(R) plots collection/R markdown/cut off_ggarrange/ICP-MS ZZH-CFY PS, H-PP, S-PP_updated.xlsx")
View(ICP_MS_ZZH_CFY_PS_H_PP_S_PP_updated)
data = ICP_MS_ZZH_CFY_PS_H_PP_S_PP_updated
data$Elements = factor(data$Elements, levels = c('Mg', 'Al', 'Ti', 'Cr', 'Mn', 'Fe', 'Co', 'Ni', 'Cu', 'Zn', 'Cd') )

Plot!

library(ggplot2)
library(ggpubr)
# 设置颜色
library(RColorBrewer)
mycolors <- colorRampPalette(c("#A6CEE3", "#1F78B4", "#B2DF8A", "#33A02C", "#FB9A99", "#E31A1C", "#FDBF6F", "#FF7F00", "#CAB2D6", "#6A3D9A", "#B15928" ))(11)
p1 <- ggplot(data,aes(x=Elements,y=`average-PS`,fill=Elements)) + geom_bar(stat='identity',position=position_dodge()) + labs(x=NULL,y='Metal concentration (ppb)',fill=NULL) +  #可自定义标签名字
coord_cartesian(ylim = c(0,5))  + scale_fill_manual(values = mycolors) + theme(axis.text = element_text(colour = 'black', size = 14), axis.ticks = element_line(colour = 'black', size = 0.6), axis.ticks.length = unit(1.2, 'mm')) + theme(legend.position = 'none', axis.title.y = element_text(size = 16))
p1

p2 = ggplot(data,aes(x=Elements,y=`average-PS`,fill=Elements)) + geom_bar(stat='identity',position=position_dodge()) + labs(x=NULL,y=NULL,fill=NULL)+   #可自定义标签名字
coord_cartesian(ylim = c(140,160))  + scale_fill_manual(values = mycolors) + theme(axis.text = element_text(colour = 'black', size = 14), axis.ticks = element_line(colour = 'black', size = 0.6), axis.ticks.length = unit(1.2, 'mm')) + theme(legend.position = 'none', axis.title.y = element_text(size = 16), axis.text.x = element_blank(), axis.ticks.x = element_blank()) + scale_y_continuous(breaks = c(140,160))
p2

p3 = ggplot(data,aes(x=Elements,y=`average-H-PP`,fill=Elements)) + geom_bar(stat='identity',position=position_dodge()) +
labs(x=NULL,y='Metal concentration (ppb)',fill=NULL)+   #可自定义标签名字
coord_cartesian(ylim = c(0,5))  + scale_fill_manual(values = mycolors) + theme(axis.text = element_text(colour = 'black', size = 14), axis.ticks = element_line(colour = 'black', size = 0.6), axis.ticks.length = unit(1.2, 'mm')) + theme(legend.position = 'none', axis.title.y = element_text(size = 16))
p3

p4 = ggplot(data,aes(x=Elements,y=`average-H-PP`,fill=Elements)) + geom_bar(stat='identity',position=position_dodge()) +
labs(x=NULL,y=NULL,fill=NULL)+  #可自定义标签名字
coord_cartesian(ylim = c(7,16)) + scale_fill_manual(values = mycolors) + theme(axis.text = element_text(colour = 'black', size = 14), axis.ticks = element_line(colour = 'black', size = 0.6), axis.ticks.length = unit(1.2, 'mm')) + theme(legend.position = 'none', axis.title.y = element_text(size = 16), axis.text.x = element_blank(), axis.ticks.x = element_blank()) + scale_y_continuous(breaks = c(7,16))
p4

p5 = ggplot(data,aes(x=Elements,y=`average-S-PP`,fill=Elements)) + geom_bar(stat='identity',position=position_dodge()) +
labs(x=NULL,y='Metal concentration (ppb)',fill=NULL)+   #可自定义标签名字
coord_cartesian(ylim = c(0,5))  + scale_fill_manual(values = mycolors) + theme(axis.text = element_text(colour = 'black', size = 14), axis.ticks = element_line(colour = 'black', size = 0.6), axis.ticks.length = unit(1.2, 'mm')) + theme(legend.position = 'none', axis.title.y = element_text(size = 16))
p5

p6 = ggplot(data,aes(x=Elements,y=`average-S-PP`,fill=Elements)) + geom_bar(stat='identity',position=position_dodge()) +
labs(x=NULL,y=NULL,fill=NULL)+  #可自定义标签名字
coord_cartesian(ylim = c(20,110))   + scale_fill_manual(values = mycolors) + theme(axis.text = element_text(colour = 'black', size = 14), axis.ticks = element_line(colour = 'black', size = 0.6), axis.ticks.length = unit(1.2, 'mm')) + theme(legend.position = 'none', axis.title.y = element_text(size = 16), axis.text.x = element_blank(), axis.ticks.x = element_blank()) + scale_y_continuous(breaks = c(20, 110))
p6

Put together!

library(patchwork)
a = p2/p1
b = p4/p3
c = p6/p5
aa = a + plot_layout(ncol = 1, heights = c(1, 3)) + xlab('PS') + theme(axis.title.x = element_text(size = 16)) + theme(axis.title.x = element_text(angle = 20, vjust = 0.8, hjust = 0.5))
bb = b + plot_layout(ncol = 1, heights = c(1, 3)) + xlab('H-PP') + theme(axis.title.x = element_text(size = 16)) + theme(axis.title.x = element_text(angle = 20, vjust = 0.8, hjust = 0.5))
cc = c + plot_layout(ncol = 1, heights = c(1, 3)) + xlab('S-PP') + theme(axis.title.x = element_text(size = 16)) + theme(axis.title.x = element_text(angle = 20, vjust = 0.8, hjust = 0.5))
aa|bb|cc