0

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))
}
wrek
  • 309
  • 2
  • 13
  • 1
    is that the full code? can you provide the data / image to make it reproducible so that we can try to help? – Hack-R Jun 11 '16 at 18:34
  • the code is long so I added the grid_arrange_shared_legend function. – wrek Jun 11 '16 at 18:58
  • Try to follow this. You don't necessarily need all the code from your production script but you need enough code and data to make it reproducible. http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example – Hack-R Jun 11 '16 at 19:25
  • 2
    How does it look if you use ggsave ("PCvsLD.tiff", dpi=500)? – dww Jun 11 '16 at 19:45
  • Thanks. The ggsave ("C:/nDesktop/Desktop/image/PCvsLD.tiff", finP, dpi=500) does the job. – wrek Jun 11 '16 at 21:12

0 Answers0