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()

Attachment: lattice_annotated_groups.pdf
Description: Adobe PDF document

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

Reply via email to