【发布时间】:2016-02-29 14:51:45
【问题描述】:
有几十对 .png 图像要组合(并作为图形与 knitr 和 LaTeX 一起包含在 PDF 文件中),我发现 grid.arrange 在图像的顶部和下方留下了很大的边距。图像的默认大小为 480 x 480 像素。我怎样才能减少那个空白?
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
注意此文本和 .png 图像开头之间的空白。
此文本标记 .png 图像的底部。
这个问题ggplot margin, not grid.arrange 不相关。
【问题讨论】: