Having dozens of pairs of .png images to combine (and include as graphics with knitr
and LaTeX
into a PDF file), I have found that grid.arrange
leaves large margins on top and below the images. The default size of the image is 480 by 480 pixels. How can I reduce that white space?
library(png)
library(grid)
img <- readPNG(system.file("img", "Rlogo.png", package="png"))
g1 <- rasterGrob(img, interpolate=TRUE, width = .3, height=.3)
g2 <- rasterGrob(img, interpolate=TRUE,width = .6, height=.6)
grid.arrange(g1, g2, nrow=1) # displays in the RStudio plot window
dev.copy(png,'r logos.png') # creates .png file in working directory
dev.off() # inserts arranged image; 53KB; 480 x 480 pixels
Note the white space between this text and the start of the .png image.
This text marks the bottom of the .png image.
This question ggplot margin, not grid.arrange is not pertinent.