I have a conundrum...
I created a function that will plot 11 plots arranged as 4x3 (i.e., mfrow=c(4,3)
) plots per device window. However, I want the function to do this multiple times with different inputs, thus generating multiple pages of 11 graphs each. The issue is that since I have one "empty" slot per page (12 - 11 = 1), I have to tell the code to start each iteration of plotting on a new window. I've done so by explicitly adding the windows()
function directly into the function. This works just fine.
The problem now, though, is if/when I want to save the output of this function as a .pdf file. Even though I wrap the function within the pdf()
device code,
pdf('savegraphics.pdf', width = 8, height = 10.5, paper = 'letter')
func(...)
dev.off()
the graphics are still opened in graphics windows in R (and never get saved to the .pdf file). I'm fairly certain that the issue causing this is the fact that I call windows()
in the original function.
So my question is:
Is there a way to "skip" to a new graphics window when creating multiple windows/pages of graphics that will also work when creating pages in a pdf?
You could do something similar to
where for your 12th plot you insert
plot.new()
.