Вы можете попробовать что-то подобное (я использовал plot_grid
из cowplot
вместо multiplot
, чтобы сократить воспроизводимый пример)
library(ggplot2)
library(ggpubr)
#> Loading required package: magrittr
library(cowplot)
#>
#> ********************************************************
#> Note: As of version 1.0.0, cowplot does not change the
#> default ggplot2 theme anymore. To recover the previous
#> behavior, execute:
#> theme_set(theme_cowplot())
#> ********************************************************
#>
#> Attaching package: 'cowplot'
#> The following object is masked from 'package:ggpubr':
#>
#> get_legend
data <- structure(list(A = c(0.99, 0.29, 0.54, 0.84, 0.58, 0.21, 0.07, 0.19, 0.33, 0.25, 0.3, 0.03, 0.59, 0.53, 0.25, 0.33, 0.06, 0.9, 0.77, 0.61, 0.26, 0.16, 0.71, 0.23, 0.57, 0.93, 0.7, 0.06), B = c(0.13, 0.84, 0.22, 0.89, 0.98, 0.78, 0.46, 0.01, 0.05, 0.5, 0.96, 0.18, 0.62, 0.18, 0.05, 0.88, 0.57, 0.55, 0.74, 0.16, 0.58, 0.35, 0.87, 0.45, 0.82, 0.26, 0.72, 0.24), C = c(0.88, 0.75, 0.99, 0.82, 0.86, 0.64, 0.66, 0.89, 0.6, 0.01, 0.71, 0.25, 0.74, 0.21, 0.46, 0.99, 0.75, 0.26, 0.42, 0.98, 0.71, 0.26, 0.31, 0.19, 0.68, 0.89, 0.02, 0.46), D = c(0.07, 0.93, 0.6, 0.5, 0.41, 0.9, 0.42, 0.69, 0.58, 0.29, 0.85, 0.56, 0.62, 0.96, 0.92, 0.7, 0.69, 0.26, 0.94,0.51, 0.24, 0.23, 0.94, 0.45, 0.55, 0.48, 0.99, 0.74), E = c(7.83, 2.69, 8.57, 0.48, 3.05, 3.32, 2.97, 6.59, 9.86, 7.64, 6.89, 0.57, 0.59, 9.68, 9.16, 1.6, 5.55, 1.38, 3.35, 8.81, 1.97, 4.25, 0.55, 0.1, 2.23, 6.85, 1.07, 5.18), F = c(3.63, 7.71, 8.53, 8.4, 6.48, 3.03, 9.35, 6.93, 1.37, 6.23, 5.08, 3.83, 0, 1.8, 2.64, 5.38, 0.02, 6.24, 7.75, 8.27, 9.14, 3.98, 5.72, 0.52, 6.83, 3.95, 0.62, 1.15), G = c(6.78, 8.23, 4.56, 2.96, 2.36, 0.02, 0.42, 4.23, 5.2, 4.8, 0.48, 7.91, 2.62, 1.71, 8.15, 0.26, 0.77, 0.31, 3.46, 3.86, 5.67, 9.07, 0.15, 5.53, 4.93, 6.82, 8.03, 8.69), H = c(14.5, 84.7, 79.1, 24.5, 75.5, 89.2, 68.2, 46.6, 79.2, 48.4, 50.3, 58.5, 63.3, 69.5, 24.5, 64.4, 47.5, 28.4, 22.2, 42.4, 65.6, 99.2, 86.3, 46.8, 67.2, 76.2, 19.4, 18.4), I = c(76.7, 12.9, 21.3, 35.5, 43.5, 18.1, 59.2, 74.1, 28.9, 96.5, 80.8, 43.6, 51.6, 28.4, 80.7, 60, 82.4, 61.5, 78.5, 67.8, 63.9, 83.6, 41.8, 47.7, 94.4, 88.9, 88.9, 100), J = c(880.3, 476.8, 686.9, 300.1, 993.4, 358, 576.5, 299.7, 494.1, 762.2, 396.7, 201.7, 416, 584.1, 699, 265.3, 729.1, 181.5, 347.8, 303.1, 967.4, 817.9, 579.1, 788.5, 482.7, 551.9, 355.9, 676.7)), class = "data.frame", row.names = c(NA, -28L))
plotComb <- combn(colnames(data), 2, simplify = FALSE)
scatterfn <- function(l, data=data){
ggscatter(data, x=l[1], y=l[2], add="reg.line", conf.int=TRUE, cor.coef=TRUE, cor.method="pearson", xlab=l[1], ylab=l[2])
}
plots <- lapply(plotComb, scatterfn, data=data)
plots <- split(plots, ceiling(seq_along(plots)/16))
pdf(file="Rplot1.pdf", width=12, height=12)
lapply(plots, function(x) plot_grid(plotlist=x, cols=4))
dev.off()
Создано в 2020-04-18 представителем пакета (v0.3.0)