I am not sure that changing the aspect ratio by using levelplot(plotMatrix[,,2], aspect = 1/0.6, ...)
will do the job as I seem to remember doing something like that when first looking at your problem. There were unwanted side effects using grid.arrange is the quick way to fill the plot area, I rarely use it You may be better off by using print - I have not got your original data so I can only guess eg print(plot2, position = c(0.2,0,0.8,0.5), more = TRUE) print(plot1 position = c(0,0.5,1.1), more = FALSE) You may have to fiddle with the position values for plot2 to get it right. If the text of plot2 is too small then you could put a line in to get plot2 par.settings = list(fontsize = list(text = 12.5, points = 8)), this is device dependent and you may need to change it Regards Duncan -----Original Message----- From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of R codeplayer Sent: Thursday, 25 June 2015 21:01 To: r-help@r-project.org Subject: Re: [R] R lattice : labeling of matrix groups of different size with strips Hi Duncan, thank you very much for your help. Originally, I thought that it is possible to use a different data representation and then to automatically create the plots and strips in lattice. Based on your suggestion, I could write the code for an annotated levelplot of the two groups (code is shown below). An open question is how to display the two groups with the same aspect ratio for the rows. > plotMatrix > , , group1 > > a b c d > 1 1 0 0 0 > 2 1 0 0 0 > 3 1 1 0 0 > 4 0 1 0 0 > 5 0 1 1 0 > > , , group2 > > a b c d > 1 0 0 1 0 > 2 0 0 1 1 > 3 0 0 0 1 > 4 NA NA NA NA > 5 NA NA NA NA library(gridExtra) trellis.device(device = "pdf",file ="lattice_annotated_groups.pdf",width=8,height=5) #The aspect="fill" option was added to coerce the same height of the 2 plots #panel.text was used instead of grid.text to avoid using the latticeExtra package plot1 <- levelplot(plotMatrix[,,1], page = function(n) panel.text("group 1", x = 0.5, y = 0.96), colorkey = F, xlab = "", ylab="", aspect="fill") pm <- plotMatrix[1:3,,2] colnames(pm) <- rep("",ncol(pm)) plot2 <-levelplot(pm, page = function(n) panel.text( "group 2", x = 0.5, y = 0.96), colorkey = F, xlab = "", ylab="", aspect="fill") grid.arrange(plot1,plot2,ncol=2) dev.off() ______________________________________________ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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.