1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
|
library(ggplot2)
library(doParallel)
library(parallel)
df <- data.frame("a" = 1:50, "b" = 1:50)
cl <- makeCluster(5)
registerDoParallel(cl)
lp <- foreach::foreach(i=1:20, .packages = c("ggplot2")) %dopar%
{
scaleMin = min(c(min(df$a), min(df$b)))
scaleMax = max(c(max(df$a), max(df$b)))
p <- qplot(x = df$a, y = df$b) +
geom_abline(intercept = 0, slope = 1, colour = "blue") + theme_bw()+
labs(x = "", y="", title = "name ")+
xlim(c(scaleMin, scaleMax)) + ylim(c(scaleMin, scaleMax))+
theme(
panel.grid.major = element_blank(), panel.grid.minor = element_blank(),
panel.background = element_rect(fill = "transparent")
)
return(p)
}
stopCluster(cl)
gp <- gridExtra::grid.arrange(grobs = lp,ncol = 3,
bottom="bottom",
left="left")
ggsave(gp, filename = "plots/allPlots.pdf",
dpi = 400, device = "pdf",
width = 400,height = 240,
units = c("mm"),limitsize = FALSE) |
Partager