Global legend using grid.arrange (gridExtra) and lattice based plots
I am producing four plots using xyplot (lattice) and further combine them with grid.arrange (gridExtra). I would like to obtain a graph with a common global legend. The closest that I have reached is the following. They have to be in a matrix layout, otherwise an option would be to put them in a column and include only a legend for the top or bottom one. # Load packages require(lattice) require(gridExtra) # Generate some values x1<-rnorm(100,10,4) x2<-rnorm(100,10,4) x3<-rnorm(100,10,4) x4<-rnorm(100,10,4) y<-rnorm(100,10,1) cond<-rbinom(100,1,0.5) groups<-sample(c(0:10),100,replace=TRUE)