[R] plot.new() and grid functions in multipage pdfs

Ali Tofigh alix.tofigh at gmail.com
Tue Oct 9 21:26:06 CEST 2012


when using the grid package, I've come across this weird behaviour
where a call to plot.new() will start a new page for a multi-page pdf,
but then the margins will somehow behave strangely for all but the
first page: here is some code:

pdf("test.pdf"); plot.new(); grid.rect(gp = gpar(fill="blue"));
plot.new();  grid.rect(gp = gpar(fill="blue")); dev.off()

The first page is filled completely with a blue rectangle, but in the
second page, the margins clip the rectangle. This is causing me
considerable headache, as I rely on many grid functions for plotting.
This seems like a bug to me, or is there something about the behaviour
of plot.new() and/or grid functions that I don't understand?


More information about the R-help mailing list