[R] size of pdf/eps output

Johannes Radinger JRadinger at gmx.at
Mon Nov 14 17:38:56 CET 2011


Hello,

I am using a grid.layout for combining multiple ggplot-plots.
So far I am doing it this way to get a pdf/eps:

pdf("/path/to/my/file.pdf") #or postscript("/path/to/my/file.eps")
grid.newpage()
pushViewport(viewport(layout = grid.layout(nrow=2, ncol=2,
			widths = unit(c(7.5,7), "cm"),
		heights = unit(rep(5, 2), "cm"))))
print(plot1, vp = viewport(layout.pos.row = 1, layout.pos.col = 1))
print(plot2, vp = viewport(layout.pos.row = 1, layout.pos.col = 2))
print(plot3, vp = viewport(layout.pos.row = 2, layout.pos.col = 1))
dev.off()

With that method I get really nice plots but there is much white space
around them. I'd like to crop the pdf/eps automatically to the maximum
extend of the plot. How can that be done? Is that a setting with viewport?

Thank you very much for your help

/Johannes


--



More information about the R-help mailing list