Hi, 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? /Ali
On Tue, Oct 9, 2012 at 1:26 PM, Ali Tofigh <alix.tofigh@gmail.com> wrote:> Hi, > > when using the grid package, I've come across this weird behaviour > > 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? >Why would you expect plot.new from base graphics to play nice with grid ? if you like/use grid graphics, stay in that world: pdf("test.pdf"); grid.rect(gp = gpar(fill="blue")); grid.newpage(); grid.rect(gp = gpar(fill="blue")); dev.off()> /Ali > > ______________________________________________ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >[[alternative HTML version deleted]]
The plot.new function is for base graphics and base and grid graphics don't usually play well together. You probably want to use grid.newpage function instead. On Tue, Oct 9, 2012 at 1:26 PM, Ali Tofigh <alix.tofigh at gmail.com> wrote:> Hi, > > 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? > > /Ali > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code.-- Gregory (Greg) L. Snow Ph.D. 538280 at gmail.com