ggplot2 - Output Plot and Table to Same Page for Each Group -


i trying output graph , table each group 1 page of pdf (one page each group). there having trouble final step. have both table , plot on same page table on top of plot. when move outside of plot window disappears. there way can put graph underneath plot (which outside of plot window)? here code:

lss <- read.csv(file="withblanksfilled_4.csv",head=true, sep=",") # read in csv , name columns st<-lss$server_type tenant <- lss$tenant_n date<- lss$date_time ss <- lss$max_load_source_size  df1 <- data.frame(st, tenant, date, ss)   #create graph populated output of dlply library(ggplot2) library(scales) library(grid) library(gridextra) library(gtable) p<-ggplot(df1, aes(x=as.date(date, "%d/%m/%y %h:%m"), y=ss))+geom_point()+labs(x="date", y="load source size")+facet_wrap(~st+tenant, ncol=1)+scale_x_date(breaks = date_breaks("week"), minor_breaks=date_breaks("1 day"), labels = date_format("%d-%b"), limits = c(as.date("2014-09-06"), as.date("2014-12-01"))) + theme(axis.text.x = element_text(size=5, color="grey"), plot.margin=unit(c(1,1,5,1), "cm"), panel.border=element_blank()) +ylim(0,na)  #p1 <- ggplot_gtable(ggplot_build(p)) #p1$layout$clip[p1$layout$name=="panel"] <- "off"  #grouping t&st library(plyr) plots<-dlply(df1, .(st, tenant), function(df1) p %+% df1 %+% annotation_custom(tablegrob(df1), ymin=-2, ymax=-2))  #outputting graphs  table pdf. pdf(file = file.path("<filepath>.pdf"), onefile=true)  plots   dev.off() 

since want tablegrob outside plot panel , not inside, shouldn't use annotation_custom, arrangegrob arrange plot , table on page. list of grobs can printed page page in pdf device.

library(plyr) plots <- dlply(iris, "species", function(d) {                arrangegrob(qplot(1,1), tablegrob(head(d)))                })  pdf("multipage.pdf") plots dev.off() 

Comments

Popular posts from this blog

python - mat is not a numerical tuple : openCV error -

c# - MSAA finds controls UI Automation doesn't -

wordpress - .htaccess: RewriteRule: bad flag delimiters -