First Page empty when printing plots in R -


i trying create pdf several plots. more specifically, want save plots, 4 in each page. therefore, have following code in r (which works, leaves page empty -the first one-):

pdf("plots/plots_numeric_four_in_page.pdf",paper="a4r",width = 14)  graphlist <- lapply(3:ncol(agg_num), function(i) {   force(i)   tempcolname=dataname_num[i]   print (tempcolname)   p<-qplot(group.1,agg_num[[tempcolname]],data = agg_num,color=group.2,geom = "line",main=tempcolname) + xlab("date") + ylab(paste("count of ", tempcolname)) +  geom_line(size=1.5)+ scale_x_date(labels = date_format("%m/%y"))+      theme(legend.position="bottom",legend.direction="horizontal")+ guides(col=guide_legend(ncol=3)) }) do.call("marrangegrob",c(graphlist,ncol=2,nrow=2)) dev.off() 

it correctly displays around 50 plots, 4 in each page correctly in pdf. however, leaves first page empty , starts second. looked @ marrangegrob options, couldnt find address problem. know workaround, or way resolve issue?

there's known bug between ggplot2 in gridextra that's causing marrangegrob's contain ggplots. manually overriding grid.draw.arrangelist function (src) (marrangegrob returns arrangelist object) may potentially fix (suggested here).

grid.draw.arrangelist <- function(x, ...) {   for(ii in seq_along(x)){     if(ii>1) grid.newpage()  # skips grid.newpage() call first time around       grid.draw(x[[ii]])   } } 

it may safer define new class arrangelist object in question , apply fix override grid.draw every marragegrob call in scope.


Comments

Popular posts from this blog

Android : Making Listview full screen -

javascript - Parse JSON from the body of the POST -

javascript - Chrome Extension: Interacting with iframe embedded within popup -