I have this part of a script:
tiff(filename = "C:/nDesktop/Desktop/image/PCvsLD.tiff", width =1200, height = 900, pointsize = 12, bg = "white", res = 96, units = "px", restoreConsole = TRUE)
finP<-grid_arrange_shared_legend(plotA, plotB,plotC, plotD)
dev.off()
When I run it I get a good low-res 96 DPI TIFF file but when I wish to increase the DPI to 500 the saved image is not fine (e.g., font size changed, missing part, parts overlapping).
How can i fix it?
grid_arrange_shared_legend function:
#code used from http://rpubs.com/sjackman/grid_arrange_shared_legend
grid_arrange_shared_legend <- function(...) {
plots <- list(...)
g <- ggplotGrob(plots[[1]] + theme(legend.position="bottom"))$grobs
legend <- g[[which(sapply(g, function(x) x$name) == "guide-box")]]
lheight <- sum(legend$height)
grid.arrange(
do.call(arrangeGrob, lapply(plots, function(x)
x + theme(legend.position="none"))),
legend,
ncol = 1,
heights = unit.c(unit(1, "npc") - lheight, lheight))
}