Dear All,
I am trying to stitch together multiple plots using ggplot2
Consider for instance the following snippet based on an old thread
(http://tinyurl.com/ylehm2t)

library(ggplot2)
vplayout <- function(x, y) viewport(layout.pos.row=x, layout.pos.col=y)

draw4 <- function(pdfname, a,b,c,d,w,h) {

   pdf(pdfname,width=w, height=h)
   grid.newpage()
   pushViewport(viewport(layout=grid.layout(2,2) ) )

       print(a, vp=vplayout(1,1))
       print(b, vp=vplayout(1,2))
       print(c, vp=vplayout(2,1))
       print(d, vp=vplayout(2,2))


   dev.off()
}

data(diamonds)


set.seed(1234)

randind <- sample(nrow(diamonds),1000,replace=FALSE)
dsmall <- diamonds[randind,]

a <-  qplot(carat, data=dsmall, geom="histogram",binwidth=1)
b <-  qplot(carat, data=dsmall, geom="histogram",binwidth=.1)
c <- qplot(carat, data=dsmall, geom="histogram",binwidth=.01)
d <- qplot(carat, data=dsmall, geom="histogram",binwidth=2)

width <- 7
height <- 7

draw4( "test-4.pdf", a,b,c,d, width, height)


Is there any way to give an overall label along the y and x axis?
E.g.something like a xlab to write some text which applies to the x axis
of all the plots and which should go at the middle bottom of the
compound plot (and something perfectly along these lines for the y axis).
Many thanks

Lorenzo

______________________________________________
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.

Reply via email to